webapp怎么判断滚动条到达底部


标题文字 ##目的:默认开始页面10条记录,判断页面到达底部了,再追加新的记录10条,依此类推。

设备:手机端 ios,android 。
环境支持:android4.0以上。

我是用了jquery的
$(window).scrollTop()+$(window).height()>=$(document).height();

此条件在android手机根本不起作用。

请问大家是否有好的办法,去判断达到了底部。

webapp web前端开发 移动web开发

王牌潜水员 10 years ago

window.onscroll = function() {


 var clientHeight = document.documentElement.scrollTop === 0 ? document.body.clientHeight : document.documentElement.clientHeight;
            var scrollTop = document.documentElement.scrollTop === 0 ? document.body.scrollTop : document.documentElement.scrollTop;
            var scrollHeight = document.documentElement.scrollTop === 0 ? document.body.scrollHeight : document.documentElement.scrollHeight;

            if (clientHeight + scrollTop === scrollHeight) {
                ajaxGetNextPage();
            }
        }

LukeMT answered 10 years ago

Your Answer