Document: hidden プロパティ

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.

Document.hidden は読み取り専用のプロパティで、ページが非表示になっているとみられるかどうかを示す論理値を返します。

ページが非表示であるかどうかを判断する代替方法としては、Document.visibilityState プロパティもあります。

論理値です。ページが非表示の場合は true、そうでなければ false です。

js
document.addEventListener("visibilitychange", () => {
  console.log(document.hidden);
  // 動作を変更...
});

仕様書

Specification
HTML
# dom-document-hidden

ブラウザーの互換性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
hidden

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.

関連情報