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.

Browser compatibility

FeatureChromeEdgeFirefoxInternet ExplorerOperaSafari
Basic support


13 webkit

FeatureAndroid webviewChrome for AndroidEdge mobileFirefox for AndroidOpera AndroidiOS SafariSamsung Internet
Basic support3333 Yes5612.117 ?

1. Doesn't fire the visibilitychange event when the browser window is minimized, nor when hidden is set to true.

See also

Document Tags and Contributors

Contributors to this page: fscholz, jpmedley, chrisdavidmills
Last updated by: fscholz,