Screen
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.
* Some parts of this feature may have varying levels of support.
TheScreen interface represents a screen, usually the one on which the current window is being rendered, and is obtained usingwindow.screen.
Note that browsers determine which screen to report as current by detecting which screen has the center of the browser window.
In this article
Instance properties
Also inherits properties from its parentEventTarget.
Screen.availHeightSpecifies 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.availWidthReturns the amount of horizontal space in pixels available to the window.
Screen.colorDepthReturns the color depth of the screen.
Screen.heightReturns the height of the screen in pixels.
Screen.isExtendedExperimentalSecure contextReturns
trueif the user's device has multiple screens, andfalseif not.Screen.orientationReturns the
ScreenOrientationinstance associated with this screen.Screen.pixelDepthGets the bit depth of the screen.
Screen.widthReturns the width of the screen.
Screen.mozEnabledNon-standardDeprecatedBoolean. Setting to false will turn off the device's screen.
Screen.mozBrightnessNon-standardDeprecatedControls the brightness of a device's screen. A double between 0 and 1.0 is expected.
Non-standard properties
The following properties are specified as part of theWindow Management API, which makes them available on theScreenDetailed interface; this is where we have chosen to document them. However, non-standard versions of these properties are available on theScreen interface in browsers that don't support that API. See this page'sBrowser compatibility table for details of the non-standard support.
Screen.availLeftRead onlyNon-standardSecure contextA number representing the x-coordinate (left-hand edge) of the available screen area.
Screen.availTopRead onlyNon-standardSecure contextA number representing the y-coordinate (top edge) of the available screen area.
Screen.leftRead onlyNon-standardSecure contextA number representing the x-coordinate (left-hand edge) of the total screen area.
Screen.topRead onlyNon-standardDeprecatedSecure contextA number representing the y-coordinate (top edge) of the total screen area.
Instance methods
Also inherits methods from its parentEventTarget.
Screen.lockOrientationDeprecatedLock the screen orientation (only works in fullscreen or for installed apps)
Screen.unlockOrientationDeprecatedUnlock the screen orientation (only works in fullscreen or for installed apps)
Events
changeExperimentalSecure contextFired on a specific screen when it changes in some way — width or height, available width or height, color depth, or orientation.
orientationchangeDeprecatedNon-standardFires when the screen orientation changes.
Examples
if (screen.colorDepth < 8) { // use low-color version of page} else { // use regular, colorful page}Specifications
| Specification |
|---|
| CSSOM View Module> # the-screen-interface> |