This is a really old question, and thus, has many outdated answers. As of 2020 all `[major browsers have adhered to the standard`][1].
document.body.scrollHeight
Edit: the above doesn't take margins on the <body> tag into account. If your body has margins, use:
document.documentElement.scrollHeight
[Ref][2]
[1]: https://caniuse.com/mdn-api_element_scrollheight
[2]: https://stackoverflow.com/questions/1145850/how-to-get-height-of-entire-document-with-javascript
This is a really old question, and thus, has many outdated answers. As of 2020 all [major browsers have adhered to the standard](https://caniuse.com/#feat=mdn-api_element_scrollheight).
**Answer for 2020:**
document.body.scrollHeight
Edit: the above doesn't take margins on the `<body>` tag into account. If your body has margins, use:
document.documentElement.scrollHeight