jQuery scrollTop()没有'不能在Safari中工作

jQuery scrollTop() doesn't work in Safari

本文关键字:不能 Safari 工作 scrollTop 没有 jQuery      更新时间:2023-09-26

我使用此函数在Chunks中加载网页,以减少主页的页面加载时间。

这在chrome和UC浏览器中运行良好。只有safari浏览器出现了问题。

这是我的代码:

if($(window).scrollTop() + $(window).height() == $(document).height())  //user scrolled to bottom of the page?
        {
}

当我要提醒循环中的某个东西时,它在iphone中也不起作用。指引我哪里做错了什么。

谢谢。

我记得,safari在jquerys窗口高度方面有问题。请尝试window.innerHeight
所以你的代码看起来像这个

if($(window).scrollTop() + window.innerHeight == $(document).height()) {
    alert('bottom')
}