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

Examples

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

Specifications

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

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: irenesmith,