How to get browser window width and height in Javascript ?

Hi Folks, I am explaining you how to get browser window width and height in Javascript . we can get dimensions of the browser window height and width peoperties using window object in javascript.

window.outerWidth : using the javascript code. it will provide overall width of the browser window.
window.outerHeight : it can provide overall height of the browser window inclusive of toolbars etc.
window.innerWidth : it can provide width of the area within the webpage area is displaying.
window.innerHeight : it can provide height of the area within which the webpage area is displaying.

Example :

<!DOCTYPE html>
<html>
<head>
   <title>How to get browser window width and height in Javascript ? </title>
</head>
<body>  
<script type="text/javascript">
   var outerWidth=window.outerWidth; 
   var outerHeight=window.outerHeight;
   var innerWidth=window.innerWidth;
   var innerHeight=window.innerHeight;

   console.log(outerWidth+' fetch outerWidth');
   console.log(outerHeight+' fetch outerHeight');
   console.log(innerWidth+' fetch innerWidth');
   console.log(innerHeight+' fetch innerHeight');



  
</script>  
</body>
</html>

Output :

Leave a Reply

Your email address will not be published. Required fields are marked *

− 1 = 4