0

I know that to find width and height of the screen it is screen.height, but what about just the browser window? Thanks.

Jeff Morse
  • 69
  • 3

2 Answers2

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