Javascript Reference - Window outerWidth and outerHeight Property








The outerWidth property returns the outer width of a window, including all interface elements.

The outerHeight property returns the outer height of a window, including all interface elements.

Browser Support

outerWidth and outerHeight Yes 9.0 Yes Yes Yes

Syntax

window.outerWidth
window.outerHeight




Return Value

An integer, representing the outer width and/or the outer height of the browser's window, including all interface elements, in pixels.

Example

The following code shows how to Get the window's height and width.


<!DOCTYPE html>
<html>
<body>
<button onclick="myFunction()">test</button>
<!--from   w  w  w  .j  a  va2  s  .co m-->
<p id="demo"></p>

<script>
function myFunction() {
    var w = window.outerWidth;
    var h = window.outerHeight;
    x = document.getElementById("demo");
    x.innerHTML = "Width: " + w + " Heigth: " + h;
}
</script>

</body>
</html>

The code above is rendered as follows: