Learn html, css, javascript online and how to make a webpage design

How to get window width and height by Javascript?

Friday 1st of January 2021 11:20:24 PMjavascriptwindow widthwindow height

Get the current frame's height and width:

var w = window.innerWidth
|| document.documentElement.clientWidth
|| document.body.clientWidth;

var h = window.innerHeight
|| document.documentElement.clientHeight
|| document.body.clientHeight;

 

Definition and Usage

The innerWidth property returns the width of a window's content area.

The innerHeight property returns the height of a window's content area.

These properties are read-only.

Note: For IE8 and earlier, you can use the clientWidth and clientHeight properties

We are Recommending you: