×

Html & Html5

it training classes Logo

The World's best Software Development Study Portal

Js Screen Object



We can use this screen object property of Javascript to get the information regarding the screen width, height, colorDepth etc.

We also know that our window is the global object so we can write it or skip it because it is by default the global object.

Let's understand the examples below where we get the width of the screen.

<html>

<body>

<script>

       document.write("<br/> screen.width: "+screen.width);

       document.write("<br/> screen.height: "+screen.height);

       document.write("<br/> screen.colorDepth: "+screen.colorDepth);

</script>

</body>

</html>

Output of this program



screen.width:1280

screen.height:720

screen.colorDepth:24



Some properties and methods are described below :-

Methods/Property Description
width returns the width of the screen
height returns the height of the screen
availWidth returns the available width
availHeight returns the available height
colorDepth returns the color depth
pixelDepth returns the pixel depth.






JS training insitute | Best IT Training classes in Gurgaon | Web Designing Training Institute