Tag: full height
Javascript to get the whole document width and height
by z3n on May.25, 2009, under Coding, Tips & Hints
Problem:
How to get document’s height and width, not only the view area or the window size, but the whole thing including the scrolling.
Solution:
There are some variants of this solution, because some browsers take this proprieties in a different way, however, here’s a little function i wrote able to return the right dimensions no matter what:
with (document.documentElement) {
var h=Math.max(clientHeight,scrollHeight);
var w=Math.max(clientWidth,scrollWidth);
}
there’s also the inner values, but they only work on certain browsers, this would be able to get the numbers you need on IE6+ , FF and mostly of the decent browsers, if you must have working on every browser check quirksmode. This will also return the highest value, meaning that if the page itself won’t fill client’s width/height, it will get the biggest value, perfect when you need to do a full page div or something like that.
Sources: