The visibilitychange event is fired when the content of a tab has become visible or has been hidden.

Bubbles Yes
Cancelable No
Interface event
Event handler property onvisibilitychange


document.addEventListener("visibilitychange", function() {
  console.log( document.visibilityState );


Specification Status Comment
Page Visibility (Second Edition)
The definition of 'visibilitychange' in that specification.

Browser compatibility

No compatibility data found. Please contribute data for "api.Document.visibilitychange" (depth: 1) to the MDN compatibility data repository.

See also

Document Tags and Contributors

Last updated by: helleborus,