JavaScript BOM Window Screen
Last Updated :
11 Jul, 2025
The Browser Object Model (BOM) is a browser-specific convention referring to all the objects exposed by the web browser. The BOM allows JavaScript to "interact with" the browser. The object of the window represents a browser window and all its corresponding features. A window object is created automatically by the browser itself. Java Script's window.screen object contains information about the user's screen. It can also be written without the window prefix.
Properties:
- screen.width
- screen.height
- screen.availWidth
- screen.availHeight
- screen.colorDepth
- screen.pixelDepth
Below examples will illustrate all the property's usage:
HTML screen.width Property: The screen.width property returns the user's screen width in pixels.
javascript
<p id="GFG"></p>
<script>
document.getElementById("GFG").innerHTML =
" The Screen width is " + screen.width;
</script>
Output:
The Screen width is 1600
HTML screen.height Property: The screen.height property returns the users screen height in pixels.
javascript
<p id="GFG"></p>
<script>
document.getElementById("GFG").innerHTML =
" The screen height is " + screen.height;
</script>
Output:
The screen height is 900
HTML screen.availWidth Property: The screen.availWidth property returns the users screen width in pixels, excluding the interface features.
javascript
<p id="GFG"></p>
<script>
document.getElementById("GFG").innerHTML =
"The available screen width is " + screen.availWidth;
</script>
Output:
The available screen width is 1549
HTML screen.availHeight Property: The screen.availHeight property returns the users screen height in pixels excluding the interface features.
javascript
<p id="GFG"></p>
<script>
document.getElementById("GFG").innerHTML =
"The available screen height is " + screen.availHeight;
</script>
Output:
The available screen height is 876
HTML screen.colorDepth Property: The screen.colorDepth property returns the bits (number) to be used to display one color. Usually, 24-bit or 32-bit hardware is used for color resolution. 24 bits = 16, 777, 216 different (True Colors) 32 bits = 4, 294, 967, 296 different (Deep Colors)
javascript
<p id="GFG"></p>
<script>
document.getElementById("GFG").innerHTML =
"The screen color depth is " + screen.colorDepth;
</script>
Output:
The screen color depth is 24
HTML screen.pixelDepth Property: The screen.pixelDepth property returns the pixel depth of the screen.
javascript
<p id="GFG"></p>
<script>
document.getElementById("GFG").innerHTML =
"The screen pixel depth is " + screen.pixelDepth;
</script>
Output :
The screen pixel depth is 24
Supported Browsers:
- Google Chrome 1 and above
- Edge 12 and above
- Firefox 1 and above
- Internet Explorer 4 and above
- Opera 12.1 and above
- Safari 1 and above
We have a Cheat Sheet on Javascript where we covered all the important topics of Javascript to check those please go through Javascript Cheat Sheet-A Basic guide to JavaScript.
Similar Reads
JavaScript - Browser Object Model The Browser Object Model (BOM) in JavaScript enables developers to interact with the browser beyond just the webpage content, offering control over essential features such as the browser window, URL (location), and browsing history.Browser Object Model in JavaScriptThe Browser Object Model (BOM) in
4 min read
Frameless Window in ElectronJS ElectronJS is an Open Source Framework used for building Cross-Platform native desktop applications using web technologies such as HTML, CSS, and JavaScript which are capable of running on Windows, macOS, and Linux operating systems. It combines the Chromium engine and NodeJS into a Single Runtime.I
9 min read
Nashorn JavaScript Engine in Java with Examples Nashorn: Nashorn is a JavaScript engine which is introduced in JDK 8. With the help of Nashorn, we can execute JavaScript code at Java Virtual Machine. Nashorn is introduced in JDK 8 to replace existing JavaScript engine i.e. Rhino. Nashorn is far better than Rhino in term of performance. The uses o
4 min read
jQWidgets jqxWindow Complete Reference The jqxWindow is a model dialog window that is used to create a user interface with ease of creation and without blocking the webpage's user interface. You can retrieve a dialog box and popup box from the window. Properties: jQWidgets jqxWindow animationType PropertyjQWidgets jqxWindow autoOpen Prop
2 min read
jQWidgets jqxDocking Complete Reference The jqxDocking is used for representing a widget to manage multiple windows and also the layout of a web page. Here each window in the specified jqxDocking can do multiple tasks such as it can be dragged around the Web page, docked into docking zones, removed from the docking, collapsed into a minim
1 min read
jQWidgets jqxDocking addWindow() Method jQWidgets is a JavaScript framework for making web-based applications for PC and mobile devices. It is a very powerful, optimized, platform-independent, and widely supported framework. The jqxDocking is used for representing a widget to manage multiple windows and also the layout of a web page. Eac
2 min read