Friday, January 26, 2018

Write a program for Window's Height and Width in javascript.

  • Two properties can be used to determine the size of the browser window.
  1. window.innerHeight - the inner height of the browser window 
  2. window.innerWidth - the inner width of the browser window
Note: Both properties return the sizes in pixels
    Program
    <html>
    <body>

    <p id="demo"></p>

    <script>
    var w = window.innerWidth
      document.documentElement.clientWidth
    document.body.clientWidth;

    var h = window.innerHeight
      document.documentElement.clientHeight
    document.body.clientHeight;

    var x = document.getElementById("demo");
    x.innerHTML = "Browser  width: " + w + ", height: " + h + ".";
    </script>

    </body>
    </html>

    Output


    0 comments:

    Post a Comment

    Thanks For Commented.

    TechTalk