Javascript has provided window.screen object that contains information regarding the user's screen. The information includes height and width, and also many other features. To find the height and width of the screen the methods provided by javascript are screen.height and screen.width respectively.
Height-syntax
scree.height;
Width-syntax
scree.width;
Example
In the following example, the width of the screen is displayed using the screen.width method.
<html> <body> <p id="width"> </p> <script> document.getElementById("width").innerHTML = "Screen width is " + screen.width; </script> </body> </html>
Output
1366
Example
In the following example, the height of the screen is displayed using the screen.height method.
<html> <body> <p id="height"> </p> <script> document.getElementById("height").innerHTML = "Screen heigth is " + screen.height; </script> </body> </html>
Output
768