Screen - Web APIs 编辑

The Screen interface represents a screen, usually the one on which the current window is being rendered, and is obtained using window.screen.

Note that browsers determine which screen to report as current by detecting which screen has the center of the browser window.

Properties

Screen.availTop This API has not been standardized.
Specifies the y-coordinate of the first pixel that is not allocated to permanent or semipermanent user interface features.
Screen.availLeft This API has not been standardized.
Returns the first available pixel available from the left side of the screen.
Screen.availHeight
Specifies the height of the screen, in pixels, minus permanent or semipermanent user interface features displayed by the operating system, such as the Taskbar on Windows.
Screen.availWidth
Returns the amount of horizontal space in pixels available to the window.
Screen.colorDepth
Returns the color depth of the screen.
Screen.height
Returns the height of the screen in pixels.
Screen.left This API has not been standardized.
Returns the distance in pixels from the left side of the main screen to the left side of the current screen.
Screen.orientation
Returns the ScreenOrientation instance associated with this screen.
Screen.pixelDepth
Gets the bit depth of the screen.
Screen.top This API has not been standardized.
Returns the distance in pixels from the top side of the current screen.
Screen.width
Returns the width of the screen.
Screen.mozEnabled This API has not been standardized. This deprecated API should no longer be used, but will probably still work.
Boolean. Setting to false will turn off the device's screen.
Screen.mozBrightness This API has not been standardized. This deprecated API should no longer be used, but will probably still work.
Controls the brightness of a device's screen. A double between 0 and 1.0 is expected.

Events handler

Screen.onorientationchange This deprecated API should no longer be used, but will probably still work.
A handler for the orientationchange event.

Methods

Screen.lockOrientation
Lock the screen orientation (only works in fullscreen or for installed apps)
Screen.unlockOrientation
Unlock the screen orientation (only works in fullscreen or for installed apps)

Methods inherited from EventTarget:

EventTarget.addEventListener()
Registers an event handler of a specific event type on the EventTarget.
EventTarget.removeEventListener()
Removes an event listener from the EventTarget.
EventTarget.dispatchEvent()
Dispatches an event to this EventTarget.

Additional methods in Mozilla chrome codebase

Mozilla includes a couple of extensions for use by JS-implemented event targets to implement onevent properties.

See also WebIDL bindings.

  • void setEventHandler(DOMString type, EventHandler handler) This API has not been standardized.
  • EventHandler getEventHandler(DOMString type) This API has not been standardized.

Example

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

Specifications

SpecificationStatusComment
CSS Object Model (CSSOM) View Module
The definition of 'Screen' in that specification.
Working DraftInitial definition.

Browser compatibility

BCD tables only load in the browser

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:85 次

字数:12379

最后编辑:7 年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文