Computer >> Computer tutorials >  >> Programming >> Javascript

What are the properties of window.screen object in JavaScript?


The window.screen object is used to get information about user’s screen in JavaScript. The following are the properties of the window.screen object in JavaScript.

  • screen.width − Width of the screen
  • screen.height − Height of the screen
  • screen.availWidth − Width of the screen excluding features like taskbar
  • screen.availHeight − Height of the screen excluding features like taskbar

Example

You can try to run the following code to learn how to work with window.screen object in JavaScript −

<!DOCTYPE html>
<html>
   <body>
      <script>
         document.write("Screen width: " + screen.width);
         document.write("<br>Screen height: " + screen.height);

         document.write("<br>Available Screen width: " + screen.availWidth);
         document.write("<br>Available Screen height: " + screen.availHeight);
      </script>
   </body>
</html>