The Document.onvisibilitychange
property represents the event handler that is called when a visibilitychange
event reaches this object.
obj.onvisibilitychange = function;
function
is the name of a user-defined function, without the () suffix or any parameters, or an anonymous function declaration.document.onvisibilitychange = function() { console.log("Visibility of page has changed!"); };
Specification | Status | Comment |
---|---|---|
Page Visibility (Second Edition) The definition of 'onvisibilitychange' in that specification. | Recommendation | Initial definition. |
Feature | Chrome | Edge | Firefox (Gecko) | Opera | Safari |
---|---|---|---|---|---|
Basic support | 13 webkit 33 | (Yes) | 56 (56) | 12.10[1] | 6.1 |
Feature | Android Webview | Chrome for Android | Edge | Firefox Mobile (Gecko) | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|
Basic support | 33 | 33 | (Yes) | 56.0 (56) | 12.10[1] | 7 |
[1] Doesn't fire the visibilitychange
event when the browser window is minimized, nor set hidden
to true
.
© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/document/onvisibilitychange