Two properties can be used to determine the size of the browser window.
Both properties return the sizes in pixels:
window.innerHeight
- the inner height of the browser
window (in pixels)
window.innerWidth
- the inner width of the browser
window (in pixels)
window.outerWidth
- returns the outer width of
a window, including all interface elements (like toolbars/scrollbars).
window.outerHeight
- returns the outer height of a window,
including all interface elements (like toolbars/scrollbars).
These properties are read-only.
var w = window.outerWidth;
var h = window.outerHeight;
var w = window.innerWidth;
var h = window.innerHeight;
<!DOCTYPE html>
<html lang="en">
<head>
<title>JavaScript</title>
</head>
<body onresize="resizeFunction()">
<script>
function resizeFunction(){
console.clear();
var iHeight = window.innerHeight;
console.log('Inner Height :' + iHeight);
var oHeight = window.outerHeight;
console.log('Outer Height :' + oHeight);
}
function resizeFunction(){
console.clear();
var iWidth = window.innerWidth;
console.log('Inner Width :' + iWidth);
var oWidth = window.outerWidth;
console.log('Outer Width :' + oWidth);
}
</script>
</body>
</html>