Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get the window height

Tags:

javascript

This is frustrating me. It should be something really simple but I can't get it to work in IE. I want to get the height of the current window: Not the scroll height, not the document height, but the actual window height. I've tried window.innerHeight which returns undefined and document.documentElement.clientHeight which gives the scroll height.

like image 955
Yo Momma Avatar asked Jun 10 '10 08:06

Yo Momma


People also ask

How do I get window height in CSS?

You can get the window height quite easily in pure CSS, using the units "vh", each corresponding to 1% of the window height. On the example below, let's begin to centralize block. foo by adding a margin-top half the size of the screen. But that only works for 'window' size.

How do I see screen height in windows?

Use window. innerWidth and window. innerHeight to get the current screen size of a page.

What is window height?

Windows are usually about three feet from the floor and approximately 18 inches from the ceiling. This leaves a header above the window, necessary for proper installation. This also leaves space beneath the window so that furniture will not obstruct or interfere much with the view.


1 Answers

For current browsers

window.innerHeight  

For IE 8 and lower, use

document.documentElement.offsetHeight; 

If you need older browsers, use:

var height = "innerHeight" in window                 ? window.innerHeight                : document.documentElement.offsetHeight;  
like image 137
Andy E Avatar answered Oct 21 '22 14:10

Andy E