Ex No: 10 GET WINDOW SIZE
Aim: To write a JavaScript code to get the window size of the open window.
Algorithm
Step1: Create a folder “Ex10” to place the HTML files.
Step2: Create HTML file “index.html”.
Step3: Use document.getElementById to get the span tag to display width and height.
Step4: Use window.innerHeight and window.innerWidth property to get the size of the window.
Step5: Use "onresize" event on the body tag to display width and height of the window when it is resized.
Source Code

index.html


<!DOCTYPE html>
<html>
   <head>
      <title>Get Window Size</title>   
   <style>
     header {
      text-align:center;
      height: 100px;
      background-color: olive;
      padding: 10px;
      border-radius: 10px 10px 0px 0px;
     }
     footer {
      text-align:center;
      font-size: 12px;
      height: 50px;
      line-height: 50px;
      background-color: olive;
      padding: 10px;
      margin-top: 20px;
      border-radius: 10px;
     }
     article{
      width: auto;
      padding: 10px;
      margin:5px;
      overflow-x: auto;
     }
     table, td, th{
      border: 1px solid;
      border-collapse: collapse;
     }
   </style>
   <script type="text/javascript">
   function getWindow()
   {
      let w, h;
      w = window.innerWidth;
      h = window.innerHeight;
      document.getElementById("width").innerHTML=w;
      document.getElementById("height").innerHTML=h;
   }
   </script>
   </head>
   <body onresize="getWindow()">      
      <header>
         <h1>Get Window Size</h1>
      </header>   
      <hr>
      <h3>Width: <span id="width"></span></h3>
      <h3>Height: <span id="height"></span></h3>
      <footer>
         Developed by K Anbarasan
      </footer>
   </body>
</html>
Result: Thus JavaScript code is written to get the window size of the open window.