Write a JavaScript program to get the width and height of the window (any time the window is resized)
Solution:
The resizeTo() method resizes a window to the specified width and height.
<!DOCTYPE html> <html> <head> <title>Window Size : height and width</title> </head> <body onload="getSize()" onresize="getSize()"> <div id="wh"> </div> </body> <script type="text/javascript"> function getSize(){ var w = document.documentElement.clientWidth; var h = document.documentElement.clientHeight; document.getElementById('wh').innerHTML = "<h1>Width: " + w + " <br> Height: " + h + "</h1>"; } </script> </html>