The JavaScript screen object holds information of browser screen. It can be used to display screen width, height, colorDepth, pixelDepth etc.
The navigator object is the window property, so it can be accessed by:
window.screen
screen
Property of JavaScript Screen Object
There are many properties of screen object that returns information of the browser.
No. | Property | Description |
---|---|---|
1 | width | returns the width of the screen |
2 | height | returns the height of the screen |
3 | availWidth | returns the available width |
4 | availHeight | returns the available height |
5 | colorDepth | returns the color depth |
6 | pixelDepth | returns the pixel depth. |
Example of JavaScript Screen Object
Let’s see the different usage of screen object.
<script>
document.writeln("<br/>screen.width: "+screen.width);
document.writeln("<br/>screen.height: "+screen.height);
document.writeln("<br/>screen.availWidth: "+screen.availWidth);
document.writeln("<br/>screen.availHeight: "+screen.availHeight);
document.writeln("<br/>screen.colorDepth: "+screen.colorDepth);
document.writeln("<br/>screen.pixelDepth: "+screen.pixelDepth);
</script>
screen.width: 1366
screen.height: 768
screen.availWidth: 1366
screen.availHeight: 728
screen.colorDepth: 24
screen.pixelDepth: 24
Leave a Reply