The Document.onvisibilitychange
property represents the event handler that is called when a visibilitychange
event reaches this object.
Syntax
obj.onvisibilitychange = function;
function
is the name of a user-defined function, without the () suffix or any parameters, or an anonymous function declaration.
Example
document.onvisibilitychange = function() { console.log("Visibility of page has changed!"); };
Specifications
Specification | Status | Comment |
---|---|---|
Page Visibility (Second Edition) The definition of 'onvisibilitychange' in that specification. |
Recommendation | Initial definition. |
Browser compatibility
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
onvisibilitychange | Chrome
Full support
33
| Edge Full support 18 | Firefox Full support 56 | IE Full support 10 | Opera
Full support
12.1
| Safari Full support 7 | WebView Android Full support 4.4.3 | Chrome Android Full support 33 | Firefox Android Full support 56 | Opera Android
Full support
12.1
| Safari iOS Full support 7 | Samsung Internet Android Full support 2.0 |
Legend
- Full support
- Full support
- See implementation notes.
- See implementation notes.
- Requires a vendor prefix or different name for use.
- Requires a vendor prefix or different name for use.