Brandon Wang Brandon Wang - 1 year ago 68
jQuery Question

Total height of the page

I'm trying to get the total height of a page using JavaScript and jQuery so I can check if the page is long enough to display something, however in my testing I am unable to get the total height of a page.

I've looked around on the Internet but things like this don't seem to be well documented, as all I can find is

, which, as I might mention, doesn't work.

Any way to use jQuery to find it?

Answer Source

Without a framework:

var _docHeight = (document.height !== undefined) ? document.height : document.body.offsetHeight;
var _docWidth = (document.width !== undefined) ? document.width : document.body.offsetWidth;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download