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.availTop Non-standard
-
Specifies the y-coordinate of the first pixel that is not allocated to permanent or semipermanent user interface features.
Screen.availLeft Non-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.left Non-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 ScreenOrientation instance associated with this screen.
-
Screen.pixelDepth
-
Gets the bit depth of the screen.
Screen.top Deprecated Non-standard
-
Returns the distance in pixels from the top side of the current screen.
-
Screen.width
-
Returns the width of the screen.
Screen.mozEnabled Non-standard Deprecated
-
Boolean. Setting to false will turn off the device's screen.
Screen.mozBrightness Non-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.lockOrientation Deprecated
-
Lock the screen orientation (only works in fullscreen or for installed apps)
Screen.unlockOrientation Deprecated
-
Unlock the screen orientation (only works in fullscreen or for installed apps)
Events
orientationchange Deprecated Non-standard
-
Fires when the screen orientation changes.
Example
if (screen.pixelDepth < 8) {
} else {
}
Specifications
Browser compatibility
|
Desktop |
Mobile |
|
Chrome |
Edge |
Firefox |
Internet Explorer |
Opera |
Safari |
WebView Android |
Chrome Android |
Firefox for Android |
Opera Android |
Safari on IOS |
Samsung Internet |
Screen |
1 |
12 |
1 |
4 |
≤12.1 |
1 |
4.4 |
18 |
4 |
≤12.1 |
1 |
1.0 |
availHeight |
1 |
12Always reflects the main screen.
|
1 |
4 |
≤12.1 |
1 |
4.4 |
18 |
4 |
≤12.1 |
1 |
1.0 |
availLeft |
1 |
79 |
1 |
No |
15 |
1 |
4.4 |
18 |
4 |
14 |
1 |
1.0 |
availTop |
1 |
79 |
1 |
No |
15 |
1 |
4.4 |
18 |
4 |
14 |
1 |
1.0 |
availWidth |
1 |
12Always reflects the main screen.
|
1 |
4 |
≤12.1 |
1 |
4.4 |
18 |
4 |
≤12.1 |
1 |
1.0 |
change_event |
100 |
100 |
No |
No |
86 |
No |
100 |
100 |
No |
69 |
No |
19.0 |
colorDepth |
1Starting with version 59 this property is no longer required to always return 24.
|
12 |
1 |
4 |
≤12.1 |
1 |
4.4Starting with version 59 this property is no longer required to always return 24.
|
18Starting with version 59 this property is no longer required to always return 24.
|
4 |
≤12.1 |
1 |
1.0Starting with Samsung Internet 7.0 this property is no longer required to always return 24.
|
height |
1 |
12 |
1 |
4 |
≤12.1 |
1 |
4.4 |
18 |
4 |
≤12.1 |
1 |
1.0 |
isExtended |
100 |
100 |
No |
No |
86 |
No |
100 |
100 |
No |
69 |
No |
19.0 |
left |
No |
No |
1 |
No |
No |
No |
No |
No |
4 |
No |
No |
No |
lockOrientation |
No |
12–79 |
14 |
11 |
No |
No |
No |
No |
14 |
No |
No |
No |
mozBrightness |
No |
No |
12 |
No |
No |
No |
No |
No |
No |
No |
No |
No |
mozEnabled |
No |
No |
12 |
No |
No |
No |
No |
No |
No |
No |
No |
No |
orientation |
38 |
79
12Edge does not return an Orientation object; instead, it returns the orientation type as a string.
|
4314 |
11Not supported on Windows 7.
|
25 |
16.4 |
39 |
39 |
4314 |
26 |
16.4 |
4.0 |
orientationchange_event |
No |
12–79 |
No |
11 |
No |
No |
No |
No |
14 |
No |
No |
No |
pixelDepth |
1Starting with version 59 this property is no longer required to always return 24.
|
12 |
1 |
9 |
≤12.1 |
1 |
4.4Starting with version 59 this property is no longer required to always return 24.
|
18Starting with version 59 this property is no longer required to always return 24.
|
4 |
≤12.1 |
1 |
1.0Starting with Samsung Internet 7.0 this property is no longer required to always return 24.
|
top |
No |
No |
1 |
No |
No |
No |
No |
No |
4 |
No |
No |
No |
unlockOrientation |
No |
12–79 |
14 |
11 |
No |
No |
No |
No |
14 |
No |
No |
No |
width |
1 |
12 |
1 |
4 |
≤12.1 |
1 |
4.4 |
18 |
4 |
≤12.1 |
1 |
1.0 |