Наши волонтёры ещё не перевели данную статью на Русский. Присоединяйтесь к нам и помогите сделать эту работу!
Вы можете также прочитать эту статью на English (US).
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
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
.
Specification
Specification | Status | Comment |
---|---|---|
CSS Object Model (CSSOM) View Module The definition of 'window.innerHeight' in that specification. |
Working Draft | Initial definition |
Browser compatibility
Desktop | Mobile | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Basic support | Chrome Full support 1 | Edge Full support Yes | Firefox
Full support
1
| IE Full support 9 | Opera Full support 9 | Safari Full support 3 | WebView Android Full support Yes | Chrome Android Full support Yes | Edge Mobile Full support Yes | Firefox Android
Full support
4
| Opera Android Full support 9 | Safari iOS Full support 3 | Samsung Internet Android ? |
Legend
- Full support
- Full support
- Compatibility unknown
- Compatibility unknown
- See implementation notes.
- See implementation notes.