[Web] Dynamically switch the title text of the website

Add the following code between Heads

<script>document.addEventListener('visibilitychange',function(){if(document.visibilityState=='hidden'){normal_title=document.title;document.title='记得回来哦~ ��';}else{document.title=normal_title;}});</script>

principle

  • Leverage the visibilitychange API
  • The visibilitychange event is fired when the browser tab is hidden or shown

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325990309&siteId=291194637