Document: hidden property

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

The Document.hidden read-only property returns a Boolean value indicating if the page is considered hidden or not.

The Document.visibilityState property provides an alternative way to determine whether the page is hidden.

Value

A Boolean value, true if the page is hidden, and false otherwise.

Examples

js
document.addEventListener("visibilitychange", () => {
  console.log(document.hidden);
  // Modify behavior…
});

Specifications

Specification
HTML
# dom-document-hidden

Browser compatibility

desktop mobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
hidden
Chrome – Full support
Chrome 13 (Release date: 2011-08-02)
prefix
prefix Implemented with the vendor prefix: webkit
Chrome – Full support
Chrome 33 (Release date: 2014-02-20)
footnote Full support
Edge – Full support
Edge 12 (Release date: 2015-07-29)
footnote Full support
Firefox – No support
Firefox 10 – 51 (Release date: 2012-01-31)
prefix
footnote Removed in 52 and later
prefix Implemented with the vendor prefix: moz
Firefox – Full support
Firefox 18 (Release date: 2013-01-08)
footnote
footnote Since Firefox 56 it also returns true on macOS when the window is completely hidden by another non-translucent application.
Opera – Full support
Opera 12.1 (Release date: 2012-11-20)
footnote Full support
Safari – Full support
Safari 7 (Release date: 2013-10-22)
footnote Full support
Chrome Android – Full support
Chrome Android 18 (Release date: 2012-06-27)
prefix
prefix Implemented with the vendor prefix: webkit
Chrome Android – Full support
Chrome Android 33 (Release date: 2014-02-26)
footnote Full support
Firefox for Android – No support
Firefox for Android 10 – 51 (Release date: 2012-01-31)
prefix
footnote Removed in 52 and later
prefix Implemented with the vendor prefix: moz
Firefox for Android – Full support
Firefox for Android 18 (Release date: 2013-01-08)
footnote
footnote Since Firefox for Android 56 it also returns true on macOS when the window is completely hidden by another non-translucent application.
Opera Android – Full support
Opera Android 12.1 (Release date: 2012-10-09)
footnote Full support
Safari on iOS – Full support
Safari on iOS 7 (Release date: 2013-09-18)
footnote Full support
Samsung Internet – Full support
Samsung Internet 1 (Release date: 2013-04-27)
prefix
prefix Implemented with the vendor prefix: webkit
Samsung Internet – Full support
Samsung Internet 2 (Release date: 2014-10-17)
footnote Full support
WebView Android – Full support
WebView Android 4.4 (Release date: 2013-12-09)
prefix
prefix Implemented with the vendor prefix: webkit
WebView Android – Full support
WebView Android 4.4.3 (Release date: 2014-06-02)
footnote Full support
WebView on iOS – Full support
WebView on iOS 7 (Release date: 2013-09-18)
footnote Full support

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
See implementation notes.
Requires a vendor prefix or different name for use.
Has more compatibility info.

See also