JQuery Detect Scroll at Bottom

后端 未结 10 853
南方客
南方客 2021-01-30 09:58

I wish to achieve content load when the user scrolls to the bottom of the page.

I am having a problem. It works fine on desktop browsers but not on mobile. I have imple

10条回答
  •  半阙折子戏
    2021-01-30 10:26

    Bullet proof way to get document height on all browsers:

    function getDocumentHeight() {
        return Math.max(
            Math.max(document.body.scrollHeight, document.documentElement.scrollHeight),
            Math.max(document.body.offsetHeight, document.documentElement.offsetHeight),
            Math.max(document.body.clientHeight, document.documentElement.clientHeight)
        );
    }
    

提交回复
热议问题