0

The below code returns the entire height, including the area we see when we scroll down.

$(window).height();

How to find the height of the visible portion of the screen?

pkja
  • 25
  • 6
  • Thanks! window.innerHeight; gives a lesser value - 638. When I try $(window).height(); for an empty web page the value is 621. Any idea why there is an extra 17px? – pkja Jul 22 '17 at 04:22
  • was you opening inspect element ?? – knizer Jul 22 '17 at 04:28

1 Answers1

-1

Try this:

var w = window.innerWidth;
var h = eindow.innerHeight;

or jQuery:

var w = $(document).width();
var h = $(document).height();
Difster
  • 3,264
  • 2
  • 22
  • 32
  • $(document).height() gives the same result as $(window).height – pkja Jul 22 '17 at 04:18
  • but window.innerHeight; gives a lesser value which is 638. When I try $(window).height(); for an empty web page the value is 621. Any idea why there is an extra 17px? – pkja Jul 22 '17 at 04:21
  • Not necessarily. Document gives you the height to the end of the dom even if it's not as long as the page or longer than the scroll. Window gives you the entire browser height regardless of where the document stops. FYI - I knew there was a difference but I had to look it up. – Difster Jul 22 '17 at 04:22