Languages
[Edit]
EN

JavaScript - get inner windows size

8 points
Created by:
Marcin
18430

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>
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