11

var window_height = $( window ).height(); this is giving current window height not the full height including scroll height. I want full window height including scroll height.

Samiul
  • 485
  • 3
  • 7
  • 15

6 Answers6

9

You should check this link: How to get height of entire document with JavaScript?

    var body = document.body,
    html = document.documentElement;

var height = Math.max( body.scrollHeight, body.offsetHeight, 
                       html.clientHeight, html.scrollHeight, html.offsetHeight );
Community
  • 1
  • 1
Niki Sharma
  • 101
  • 3
3

As of 2020 the best way to find the height of an entire document is:

document.documentElement.scrollHeight

Credit: this answer on another question.

Max Stevens
  • 101
  • 1
  • 7
1

Yes this is

$("body").height()
Pang
  • 9,564
  • 146
  • 81
  • 122
Samiul
  • 485
  • 3
  • 7
  • 15
  • Nope - visible only. One of my divs is much more. I want the total of everything in and out of view. – JosephK Mar 22 '17 at 18:56
0

Use:

function getheight(){
    var d= document.documentElement;
    var b= document.body;
    var who= d.offsetHeight? d: b ;
    return Math.max(who.scrollHeight,who.offsetHeight);
}
getheight()
Pang
  • 9,564
  • 146
  • 81
  • 122
Milind Anantwar
  • 81,290
  • 25
  • 94
  • 125
0

None of the above worked for me - all gave viewport-height. I had to wrap the entire page in a div (class 'wrapper'), then get it with:

    $('.wrapper').prop('scrollHeight');
JosephK
  • 668
  • 10
  • 18
0

Use $(document).height(); to get full height with scrollable area.

Use $(window).height(); to get only viewable area height.

Important : The document height is the entire height of the whole document, even what is outside the viewable area. The window height is just the viewable area.

Arif
  • 6,094
  • 4
  • 49
  • 81