JavaScript Screen
Summary: in this tutorial, you will learn how to use the JavaScript Screen object to get the screen’s information of the current.
Introduction to the JavaScript Screen object
The Screen object provides the attributes of the screen on which the current window is being rendered.
To access the Screen object, you use the screen property of the window object:
window.screenCode language: JavaScript (javascript)
The Screen object is typically used by the web analytic software like Google Analytics to collect information of the client device on which the web browsers are running.
JavaScript Screen properties
The window.screen object provides the following properties:
| Property | Description |
|---|---|
| availTop | A read-only property that returns the first pixel from the top that is not taken up by system elements. |
| availWidth | A read-only property that returns the pixel width of the screen minus system elements. |
| colorDepth | A read-only property that returns the number of bits used to represent colors. |
| height | Represents the pixel height of the screen. |
| left | Represents the pixel distance of the current screen’s left side. |
| pixelDepth | A read-only property that returns the bit depth of the screen. |
| top | Represents the pixel distance of the current screen’s top. |
| width | Represents the pixel width of the screen. |
| orientation | Returns the screen orientation as specified in the Screen Orientation API |
| availTop | A read-only property that returns the first pixel from the top that is not taken up by system elements. |
| availWidth | A read-only property that returns the pixel width of the screen minus system elements. |
| colorDepth | A read-only property that returns the number of bits used to represent colors. |
| height | Represents the pixel height of the screen. |
| left | Represents the pixel distance of the current screen’s left side. |
| pixelDepth | A read-only that returns the bit depth of the screen. |
| top | Represents the pixel distance of the current screen’s top. |
| width | Represents the pixel width of the screen. |
| orientation | Returns the screen orientation as specified in the Screen Orientation API |