This article brings the content is about the HTML5 page visibility of the Judgment (with code), there is a certain reference value, the need for a friend can refer to, I hope you have some help.
visibilitychange
Page events to determine the status of the current page visibility and perform certain tasks specifically
Document.hidden
The newly-emerged document.hidden
property that shows whether the page is the user's currently viewing page, with a value of ture or false.
Document.visibilitystate
visibilityState
The value is either visible
(indicates that the page is currently active tab for the browser and the window is not minimized), either (the page is not the Active hidden
tab page, or the window is minimized.) ), or prerender
(the page is regenerated, not visible to the user.) ).
Visibilitychange Events
Various browsers compatible with VAR hidden, state, visibilitychange; if (typeof Document.hidden!== "undefined") { hidden = "hidden"; Visibilitychange = "Visibilitychange"; State = "Visibilitystate"; } else if (typeof Document.mozhidden!== "undefined") { hidden = "Mozhidden"; Visibilitychange = "Mozvisibilitychange"; State = "Mozvisibilitystate"; } else if (typeof Document.mshidden!== "undefined") { hidden = "Mshidden"; Visibilitychange = "Msvisibilitychange"; State = "Msvisibilitystate"; } else if (typeof Document.webkithidden!== "undefined") { hidden = "Webkithidden"; Visibilitychange = "Webkitvisibilitychange"; State = "Webkitvisibilitystate"; }//Add listener, Show status change in title Document.addeventlistener (Visibilitychange, function () { document.title = document[ State]; }, False);//Initialize document.title = Document[state];
Add Listener
Document.addeventlistener ("Visibilitychange", function () { console.log (document.visibilitystate);}); Document.addeventlistener ("Msvisibilitychange", function () { console.log (document.msvisibilitystate);}); Document.addeventlistener ("Mozvisibilitychange", function () { console.log (document.mozvisibilitystate);}); Document.addeventlistener ("Webkitvisibilitychange", function () { console.log (document.webkitvisibilitystate) ;});
Related articles recommended:
A brief introduction to abstract methods and abstract classes and interfaces in PHP
What are containers (Container) and facades (facade)? Analysis of container and façade in thinkphp5.1
thinkphp template How to determine whether to pay by mobile phone or scan code