How can i get the height of overflowed part in my document.
Example: I resized the window and scrollbar appear, how can i obtain the height of the part that is out of the window.
Thanks in advance.
The basic equation here is
documentHeight == windowHeight + scrollTop + scrollBottom ~ scrollBottom == documentHeight - windowHeight - scrollTop
var winH = document.documentElement.clientHeight; var docH = document.body.clientHeight; var scrollTop = (window.pageYOffset !== undefined) ? window.pageYOffset : (document.documentElement || document.body.parentNode || document.body).scrollTop; var scrollBottom = docH - winH - scrollTop;
http://jsfiddle.net/QTHuL/show (fullscreen, can be tested in old browsers)
In jQuery it's even simpler:
var winH = $(window).height(); var docH = $(document).height(); var scrollTop = $(window).scrollTop(); var scrollBottom = docH - winH - scrollTop;
The height of the document (all content) less the height of the viewport.
$(document).height() - $(window).height()