Languages
[Edit]
EN

JavaScript - get inner windows size

8 points
Created by:
Rubi-Reyna
677

In this short article we would like to show how to get inner window size in pure JavaScript. Inner window size we understand as area where web page is drawn.

Quick solution: 

var width = window.innerWidth;
var height = window.innerHeight;

console.log(width + 'x' + height);

Practical example

To see effect in the example we used onresize event.

// ONLINE-RUNNER:browser;

<html>
<body>
  <div>Some page content here ...</div>
  <script>
    
    window.onresize = function() {
      	var width = window.innerWidth;
        var height = window.innerHeight;

      	console.clear();
        console.log(width + 'x' + height);
    };

  </script>
</body>
</html>
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join