Javascript window screen object provides the functionality to detect the display area i.e. screen properties of a browser. Javascript screen object can be used with or without window object e.g.: window.screen or directly screen. When we use window.screen it represents the browser window and its screen object. If we use screen object directly it automatically detects the browser window object that is created dynamically by Javascript runtime engine and collects the information about client browser as well as display screen. Javascript screen object enables you to detect the browser’s usable area also.
Javascript Window Screen Object Properties
Following are the commonly used properties of javascript screen object that are also accessible in almost all the modern browsers:
1. availWidth: returns the available width of the display screen of the computer monitor based on resolution of the screen. availWidth property of screen object gives approximate value of width available to display the content in a browser along x-axis. availWidth property returns the width in pixels without excluding the width of window’s taskbar coz in Windows operation system, according to default settings, position of taskbar is bottom of display screen.
2. availHeight: returns the available height of the display screen of the computer monitor based on resolution of the screen. availHeight property of screen object gives approximate value of height available to display the content in a browser along y-axis. availHeight property returns the height in pixels excluding the height of window’s taskbar coz in Windows operation system, according to default settings, position of taskbar is bottom of display screen that reduces the available height for the web browsers.
3. colorDepth: returns the bit depth of the color palette retrieved from the graphic properties of the computer system. colorDepth property of the javascript screen object returns the color quality property of the client’s computer such as 16 bit, 24 bit or 32 bit that depends upon graphics card and its memory (buffer).
4. height: returns the height of display screen. Height property of javascript screen object actually returns the number of pixels in vertical direction i.e. vertical value for screen resolution along y-axis.
5. width: returns the width of display screen. Width property of javascript screen object actually returns the number of pixels in horizontal direction i.e. horizontal value for screen resolution along x-axis.
Continue to next tutorial: Javascript screen availWidth property to learn how to get available screen width.