CodesJava

Easy learning with example program codes

javascript Screen object

Screen object

The javascript screen object is the window property which is used to hold information of browser screen and to display informations related to screen. It is a property of window object and thus can be written as window.screen or only screen.

Properties of Screen Object:

PROPERTYUSES
screen.availWidthTo get the available width of the screen.
screen.availHeightTo get the available height of the screen.
screen.colorDepthTo get the color depth of the screen.
screen.heightTo get the height of the screen.
screen.pixelDepthTo get the pixel depth of the screen.
screen.widthTo get the width of the screen.

 

Example:

<!DOCTYPE html>
<html>
<body>
 
<p id="navigator1"></p>
<p id="navigator2"></p>
<p id="navigator3"></p>
<p id="navigator4"></p>
<p id="navigator5"></p>
<p id="navigator6"></p>
 
<script>
document.getElementById("navigator1").innerHTML =
"Screen Width: " + screen.width;
document.getElementById("navigator2").innerHTML = "Screen Height: " + screen.height;
document.getElementById("navigator3").innerHTML =
"Available Screen Width: " + screen.availWidth;
document.getElementById("navigator4").innerHTML =
"Available Screen Height: " + screen.availHeight;
document.getElementById("navigator5").innerHTML = "Screen Color Depth: " + screen.colorDepth;
document.getElementById("navigator6").innerHTML =
"Screen Pixel Depth: " + screen.pixelDepth;
</script>
 
</body>
</html>

Output:

Screen Width: 1366
Screen Height: 768
Available Screen Width: 1366
Available Screen Height: 732
Screen Color Depth: 24
Screen Pixel Depth: 24
Please follow and like us:
error








Copyright © 2019 CodesJava DMCA.com Protection Status