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.
Asked
Active
Viewed 1.5k times
6 Answers
8
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
- 91
- 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
- 91
- 7
1
-
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,073
- 146
- 84
- 117
Milind Anantwar
- 79,642
- 23
- 92
- 120
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
- 658
- 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
- 5,276
- 3
- 45
- 76