Screen
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.
Instance properties
Also inherits properties from its parent EventTarget.
Screen.availTopNon-standard-
Specifies the y-coordinate of the first pixel that is not allocated to permanent or semipermanent user interface features.
Screen.availLeftNon-standard-
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.leftNon-standard-
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
ScreenOrientationinstance associated with this screen. Screen.pixelDepth-
Gets the bit depth of the screen.
Screen.topDeprecated Non-standard-
Returns the distance in pixels from the top side of the current screen.
Screen.width-
Returns the width of the screen.
Screen.mozEnabledNon-standard Deprecated-
Boolean. Setting to false will turn off the device's screen.
Screen.mozBrightnessNon-standard Deprecated-
Controls the brightness of a device's screen. A double between 0 and 1.0 is expected.
Instance methods
Also inherits methods from its parent EventTarget.
Screen.lockOrientationDeprecated-
Lock the screen orientation (only works in fullscreen or for installed apps)
Screen.unlockOrientationDeprecated-
Unlock the screen orientation (only works in fullscreen or for installed apps)
Events
orientationchangeDeprecated Non-standard-
Fires when the screen orientation changes.
Example
js
if (screen.pixelDepth < 8) {
// use low-color version of page
} else {
// use regular, colorful page
}
Specifications
| Specification |
|---|
| CSSOM View Module # the-screen-interface |
Browser compatibility
BCD tables only load in the browser