I know that to find width and height of the screen it is screen.height, but what about just the browser window? Thanks.
Asked
Active
Viewed 98 times
0
-
window.height ... window.width?? – Rajshekar Reddy Apr 22 '16 at 01:31
-
in css you can use `vw`:(1% of viewport width) and `vh`:(1% of viewport height) – trex005 Apr 22 '16 at 01:33
-
3Possible duplicate of [Get the size of the screen, current web page and browser window](http://stackoverflow.com/questions/3437786/get-the-size-of-the-screen-current-web-page-and-browser-window) – Yuriy Yakym Apr 22 '16 at 01:35
2 Answers
0
You need to use window.innerWidth
and window.innerHeight
#Side note #1:
You can also use outerWidth
and outerHeight
, but this will return the window's toolbars, etc.
Side note #2: This snippet will show the snippet's width and height because it treats it as the window, not the actual window, but it will work in a true website.
alert("Window Height: "+window.innerHeight);
alert("Window Width: "+window.innerWidth);

Wowsk
- 3,637
- 2
- 18
- 29
0
var w = window.innerWidth;
var h = window.innerHeight;
Gets the window's height and width: (NOT including toolbars/scrollbars):
The innerWidth
property returns the inner width of a window's content area.
The innerHeight
property returns the inner height of a window's content area.
These properties are read-only.
Note: Use the outerWidth
and outerHeight
properties to get the width/height with toolbars/scrollbars.

Rajshekar Reddy
- 18,647
- 3
- 40
- 59