W3cubDocs

/DOM

window.innerHeight

Height (in pixels) of the browser window viewport including, if rendered, the horizontal scrollbar.

Syntax

var intViewportHeight = window.innerHeight;

Value

On return, intViewportHeight is the height of the browser window's viewport.

The window.innerHeight property is read only; it has no default value.

Notes

The innerHeight property is supported in any window object like a window, a frame, a frameset, or a secondary window.

There is an algorithm to obtain the height of the viewport excluding, if rendered, the horizontal scrollbar.

Example

Assuming a frameset

var intFrameHeight = window.innerHeight; // or

var intFrameHeight = self.innerHeight;
// will return the height of the frame viewport within the frameset

var intFramesetHeight = parent.innerHeight;
// will return the height of the viewport of the closest frameset

var intOuterFramesetHeight = top.innerHeight;
// will return the height of the viewport of the outermost frameset

To change the size of a window, see window.resizeBy() and window.resizeTo().

To get the outer height of a window, i.e. the height of the whole browser window, see window.outerHeight.

Graphical example

The following figure shows the difference between outerHeight and innerHeight.

innerHeight vs outerHeight illustration

Specification

Browser compatibilityUpdate compatibility data on GitHub

Desktop
Chrome Edge Firefox Internet Explorer Opera Safari
Basic support 1 Yes 1
1
4 — 24
This property was buggy and could give a wrong value before page load in certain circumstances, see bug 641188.
9 9 3
Mobile
Android webview Chrome for Android Edge Mobile Firefox for Android Opera for Android iOS Safari Samsung Internet
Basic support Yes Yes Yes 4
4
4 — 24
This property was buggy and could give a wrong value before page load in certain circumstances, see bug 641188.
9 3 ?

See also

© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/window/innerHeight