Your Search Results


    This article is in need of a technical review.

    « Window


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

    Note: If you use nsIDOMWindowUtils.setCSSViewport() to set the virtual window size for page layout purposes, the value returned by this property corresponds to the viewport height set using that method.


    var intViewportHeight = window.innerHeight;


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

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


    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.


    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

    FIXME: link to an interactive demo here

    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

    Browser compatibility

    Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
    Basic support 1 1.0 (1.7 or earlier) 9 9 3
    Feature Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
    Basic support 1 1.0 (1.0) 9 9 3

    Gecko note

    Since Firefox 4 to Firefox 24, this property was buggy and could give a wrong value before page load on certain circumstances, see bug 641188.

    Standards information

    DOM Level 0. Not part of any W3C technical specification or recommendation.

    See also


    File Size Date Attached by
    1074 bytes 2005-10-23 10:41:15 KamielMartinet
    38683 bytes 2005-05-04 00:39:15 GT

    Document Tags and Contributors

    Last updated by: teoli,
    Hide Sidebar