Javascript Browser Window outerWidth and outerHeight Property

Introduction

Get the browser window's height and width:

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

Click the button to display this browser window's height and width including toolbars and scrollbars.

View in separate window

<!DOCTYPE html>
<html>
<body>
<button onclick="myFunction()">Test</button>
<p id="demo"></p>

<script>
function myFunction() {//from  www . j av a  2 s.co m
  var w = window.outerWidth;
  var h = window.outerHeight;
  document.getElementById("demo").innerHTML = "Width: " + w + "<br>Height: " + h;
}
</script>

</body>
</html>

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

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

These properties are read-only.

The outerWidth property returns a Number representing the width and/or the height of the browser's window, including all interface elements, in pixels




PreviousNext

Related