Home  >  Article  >  Web Front-end  >  Example of js monitoring browser tab page switching

Example of js monitoring browser tab page switching

巴扎黑
巴扎黑Original
2016-11-25 10:13:372024browse

I have been searching online for a long time, and I have always wanted to implement this kind of monitoring event similar to the window switching and title changing on the Ele.me website. . .
The hard work paid off and I finally found it. . .
Coincidentally, the questioner also used Ele.me as an example. . .
https://zhidao.baidu.com/question/754828658481567564.html

Javascript code

<script> </p> <p>document.addEventListener('visibilitychange',function(){ </p> <p> if(document .visibilityState= ='hidden') { </p> <p> normal_title=document.title; </p> <p> document.title='(づ ̄3 ̄)づ'; </p> <p> } </p> <p>else </p> <p> document.title=normal_title; </p> <p>}); </p> <p></script>


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:js timerNext article:js timer