Document.onvisibilitychange

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
Page Visibility Level 2 (Page Visibility 2)
# dom-document-onvisibilitychange

Browser compatibility

BCD tables only load in the browser

See also