EN
JavaScript - get inner windows 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:
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>