How to get the browser window size when the browser window is resized in JavaScaript

1 Answer

0 votes
<!DOCTYPE html>
<html>

<head>  
</head>
  
<body onresize="GetWindowSize()">

<script>        

function GetWindowSize() 
{
    var width = window.outerWidth;
    var height = window.outerHeight;
    
    document.getElementById("p-id").innerHTML = "Browser window width: " + 
                                                 width + ", height: " + height;
}

/*
run:

Browser window width: 976, height: 1160
  
*/

</script>

<p id="p-id"></p>

</body>
</html>

 



answered Aug 27, 2015 by avibootz
...