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

Example of js monitoring browser tab page switching

巴扎黑
Release: 2016-11-25 10:13:37
Original
2087 people have browsed it

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>


Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template