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

View in English Always switch to English

Window.screen

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月⁩.

返回当前 window 的 screen 对象。screen 对象实现了Screen接口,它是个特殊的对象,返回当前渲染窗口中和屏幕有关的属性。

语法

screenObj = window.screen;

示例

js
if (screen.pixelDepth < 8) {
  // use low-color version of page
} else {
  // use regular, colorful page
}

Specification

TBD