document visibilityState visibilitychange




<!
DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> </head> <body> <div class="con"></div> </body> <script type="text/javascript"> document.addEventListener("visibilitychange",function(){ if(document.visibilityState=="visible"){ console.log("欢迎回来!") //do something //继续视频播放 } if(document.visibilityState=="hidden"){ console.log("不要走!") //do something else //暂停视频播放 } }) </script> </html>

 

posted @ 2021-02-05 22:14  AngDH  阅读(52)  评论(0编辑  收藏  举报