How to get the scroll position value of a document?
It uses HTML DOM Elements, but not jQuery selector. It can be used like:
var height = document.body.scrollHeight;
You can try this for example, this code put the scrollbar at the bottom for all DIV tags
Remember: jQuery can accept a function instead the value as argument. "this" is the object treated by jQuery, the function returns the scrollHeight property of the current DIV "this" and do it for all DIV in the document.
$("div").scrollTop(function(){return this.scrollHeight})
Something like this should solve your problem:
$.getDocHeight = function(){
var D = document;
return Math.max(Math.max(D.body.scrollHeight, D.documentElement.scrollHeight), Math.max(D.body.offsetHeight, D.documentElement.offsetHeight), Math.max(D.body.clientHeight, D.documentElement.clientHeight));
};
alert( $.getDocHeight() );
Ps: Call that function every time you need it, the alert is for testing purposes..