solvit.io

Get the browser window dimensions (height and width) with JavaScript

Solution
var height = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);
var width = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
Example

This example shows the dimensions of your current browser window in real-time. Resize your browser to see the updated actual dimensions:

Height:

Width:

Find more solutions about: , ,