Using jQuery (which you did specify), $(document).height()
will return exactly what you're asking for.
To clarify the usage of the height()
method:
$('.someElement').height(); // returns the calculated pixel height of the element(s)
$(window).height(); // returns height of browser viewport
$(document).height(); // returns height of HTML document
I suspect, that if $(document).height()
is not working for you, something is wrong. You may be:
- Calling it too early. Like, before the DOM is ready
- Have some uncleared floats that are not causing some block level elements to expand to their real height. Thus messing up height calculations.
- Have something critical absolutely positioned. Absolutely positioned elements do not contribute towards height calculations of their parent elements.