ianyang — 2010-06-17T21:38:04-04:00 — #1
As shown in the following figure. How do I get the height?
felgall — 2010-06-17T21:51:57-04:00 — #2
var viewportheight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
ianyang — 2010-06-17T21:56:03-04:00 — #3
I was using $('html').height() of jQuery but it didn't work. Strange.
felgall — 2010-06-17T22:33:11-04:00 — #4
That would be trying to get the height of the content of the HTML tag rather than the height of the browser viewport.
ianyang — 2010-06-18T06:46:15-04:00 — #5
But in XHTML, isn't the documentElement always the <html> element?
felgall — 2010-06-18T18:03:26-04:00 — #6
The height of the page is completely different from the height of the browser viewport. The height of the browser viewport is the same regardless of whether a page is 10 pixels or 10 million pixels long. A short page will have a blank space at the bottom of the viewport. A long page will either have a scrollbar to allow the page to scroll or will have whatever doesn't fit the viewport inaccessible.
documentElement.clientHeight only supplies the viewport height in IE when a strict doctype is used.
Iin XHTML the viewport height is always supplied by window.innerHeight and the other two alternatives are not needed (as they are only used by IE which doesn't support XHTML).
scallioxtx — 2010-06-18T19:31:27-04:00 — #7
In jQuery it's $(window).height()
ianyang — 2010-06-18T23:32:34-04:00 — #8
ianyang — 2010-06-18T23:33:08-04:00 — #9