javascript移动交叉浏览器确定用户是否滚动到页面底部

javascript mobile crossbrowser determine if user scrolled to the bottom of page

本文关键字:滚动 是否 底部 用户 移动 浏览器 javascript      更新时间:2023-09-26

你好,我的问题位于:

javascript跨浏览器确定用户是否滚动到页面的底部

我怎么能把它写成与手机兼容?

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

感谢

我不知道这是否有帮助。

正如你所说,你可以获得当前的scrollHeight,如果你在页面底部放置锚点?并使用脚本作为

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