Window outerWidthandouterHeightProperty

Window 对象 参考手册Window Object

Definition and Usage

The outerHeight property sets or returns the outer height of a window, including all interface elements (such as toolbars/scrollbars).

The outerWidth property sets or returns the outer width of a window, including all interface elements (such as toolbars/scrollbars).

outerWidth and outerHeight are read-only properties.

Note:UseinnerWidth and innerHeightproperties to get the window height and width excluding toolbars and scrollbars.

Syntax

Get the width and height of the window:

window.outerWidth
window.outerHeight

Set the width and height of the window:

window.outerWidth=pixels
window.outerHeight=pixels


Browser Support

The numbers in the table specify the first browser version that fully supports the property.

Property
outerWidth 1.0 9.0 1.0 3.0 9.0
outerHeight 1.0 9.0 1.0 3.0 9.0

Example

Example

Get the height and width of the window (including toolbars/scrollbars):

var w=window.outerWidth; var h=window.outerHeight;

Try it Yourself »

The following demonstrates the use of innerWidth, innerHeight, outerWidth and outerHeight:

Example

var txt = ""; txt += "<p>innerWidth: " + window.innerWidth + "</p>"; txt += "<p>innerHeight: " + window.innerHeight + "</p>"; txt += "<p>outerWidth: " + window.outerWidth + "</p>"; txt += "<p>outerHeight: " + window.outerHeight + "</p>";

Try it Yourself »


Window 对象参考手册Window Object Other Extensions