JS – BOM – Browser Object Model – Get Window Size

Get the window size:

<!DOCTYPE html>
<html>
<body>

<p id="demo"></p>

<script>
// For Internet Explorer, Chrome, Firefox, Opera, and Safari
var w=window.innerWidth
|| document.documentElement.clientWidth   // OR logical operation
|| document.body.clientWidth;

// For Internet Explorer 8, 7, 6, 5
var h=window.innerHeight
|| document.documentElement.clientHeight  // OR logical operation
|| document.body.clientHeight;

x=document.getElementById("demo");
x.innerHTML="Browser inner window width: " + w + ", height: " + h + "."
</script>

</body>
</html>

The result is:
Browser inner window width: 532, height: 667.

My official WebSite >