javascript mobile crossbrowser确定用户是否滚动到页面底部

时间:2012-09-11 19:27:07

标签: javascript android iphone mobile

您好我的问题位于:

javascript crossbrowser determine if user scrolld to the bottom of page

我怎么能把它写成移动兼容的?

window.onscroll = function () {
if (document.body.scrollHeight == (document.body.scrollTop + document.body.clientHeight)) {
            alert("ok");
        }
    }

谢谢

1 个答案:

答案 0 :(得分:1)

我不知道这是否有所帮助。

正如你所说,你可以得到当前的scrollHeight,如果你发生了什么 在页面底部放置一个锚点?并使用脚本

var curr = document.body.scrollHeight;
document.location.href = "#bottompage";
if(curr == document.body.scrollHeight) {
  alert("Bottom of page");
}
相关问题