EN
JavaScript - get inner window size
8 points
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:
xxxxxxxxxx
1
var width = window.innerWidth;
2
var height = window.innerHeight;
3
4
console.log(width + 'x' + height);
To see effect in the example we used onresize
event.
xxxxxxxxxx
1
<html>
2
<body>
3
<div>Some page content here ...</div>
4
<script>
5
6
window.onresize = function() {
7
var width = window.innerWidth;
8
var height = window.innerHeight;
9
10
console.clear();
11
console.log(width + 'x' + height);
12
};
13
14
</script>
15
</body>
16
</html>