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:

PropertyDescription
availTopA read-only property that returns the first pixel from the top that is not taken up by system elements.
availWidthA read-only property that returns the pixel width of the screen minus system elements.
colorDepthA read-only property that returns the number of bits used to represent colors.
heightRepresents the pixel height of the screen.
leftRepresents the pixel distance of the current screen’s left side.
pixelDepthA read-only property that returns the bit depth of the screen.
topRepresents the pixel distance of the current screen’s top.
widthRepresents the pixel width of the screen.
orientation Returns the screen orientation as specified in the Screen Orientation API
availTopA read-only property that returns the first pixel from the top that is not taken up by system elements.
availWidthA read-only property that returns the pixel width of the screen minus system elements.
colorDepthA read-only property that returns the number of bits used to represent colors.
heightRepresents the pixel height of the screen.
leftRepresents the pixel distance of the current screen’s left side.
pixelDepthA read-only that returns the bit depth of the screen.
topRepresents the pixel distance of the current screen’s top.
widthRepresents the pixel width of the screen.
orientation Returns the screen orientation as specified in the Screen Orientation API

 

Was this tutorial helpful ?