Sometimes it's important to find out maximum scrollable height of page. using this simple cross platform snippet it's really easy

``` var limit = Math.max( document.body.scrollHeight, document.body.offsetHeight, document.documentElement.clientHeight, document.documentElement.scrollHeight, document.documentElement.offsetHeight ); ```

If you want to find maximum scroll x-position you just need to minus `limit` by `window.innerHeight`

``` var limit = Math.max( document.body.scrollHeight, document.body.offsetHeight, document.documentElement.clientHeight, document.documentElement.scrollHeight, document.documentElement.offsetHeight ); var xPosition = limit - window.innerHeight; ```