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
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
Java Swing | JWindow with examples JWindow is a part of Java Swing and it can appear on any part of the users desktop. It is different from JFrame in the respect that JWindow does not have a title bar or window management buttons like minimize, maximize, and close, which JFrame has. JWindow can contain several components such as butt
5 min read
Java AWT Panel In Java's Abstract Window Toolkit (AWT), the Panel class is a fundamental component for creating graphical user interfaces. It offers a straightforward way to organize and group various GUI elements. This article explores the Panel class in Java AWT, covering its essential aspects, methods, and cons
2 min read
Java AWT Tutorial Java AWT or Abstract Window Toolkit is an API used for developing GUI(Graphic User Interfaces) or Window-Based Applications in Java. Java AWT is part of the Java Foundation Classes (JFC) that provides a way to build platform-independent graphical applications.In this AWT tutorial, you will learn the
13 min read