1. 面向开发者的 Web 技术
  2. Web API
  3. Document
  4. Document:hidden 属性

此页面由社区从英文翻译而来。了解更多并加入 MDN Web Docs 社区。

View in English Always switch to English

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 ⁨2015年7月⁩.

Document.hidden 只读属性返回一个表示页面是否被视为隐藏的布尔值。

Document.visibilityState 属性提供了另一种确定页面是否隐藏的方法。

布尔值,如果页面隐藏则为 true,否则为 false

示例

js
document.addEventListener("visibilitychange", () => {
 console.log(document.hidden);
 // 修改行为......
});

规范

Specification
HTML
# dom-document-hidden

浏览器兼容性

参见

Help improve MDN

Learn how to contribute

This page was last modified on by MDN contributors.

AltStyle によって変換されたページ (->オリジナル) /