简体   繁体   English

如何检测我的文档已到达移动设备的页面底部?

[英]How to detect my document has reached the page bottom on mobile devices?

How can I detect my document has reached the page bottom on mobile devices? 如何检测我的文档已到达移动设备的页面底部?

I have this code works perfectly on desktop devices, but not on mobile devices, such as android phones, 我的这段代码可以在台式机设备上完美运行,但不能在移动设备(例如android手机)上运行,

$(window).scroll(function() {
if($(window).scrollTop() + $(window).height() == $(document).height()) {
alert("bottom!");
}
});

any idea what else should I include in the code to make it work on mobile? 知道我还应该在代码中包含哪些内容才能使其在移动设备上运行吗?

I am using it for infinite scroll. 我正在使用它进行无限滚动。 I have a "load more" link on nearly bottom of page. 我在页面底部几乎有一个“加载更多”链接。

jQuery( window ).scroll( function() {
    var loadMoreLink = 'a.infinite-link';   
    var actualLink = jQuery( loadMoreLink );

    if ( actualLink.length ) {
        var currentPosition = jQuery( loadMoreLink ).offset();
        var pixelsVisible = window.innerHeight - currentPosition.top + jQuery( window ).scrollTop();

        if ( pixelsVisible > 100 ) {
            // time to do some ajax call.
        }            
    }
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何检测滚动条何时到达网页的顶部或底部? - How to detect when the scrollbar has reached the top or bottom of webpage? 检测scrollview是否到达底部钛 - detect if scrollview has reached the bottom titanium 如何检测滚动视图何时到达底部,以便可以向其中加载更多项目? - How can I detect when a scrollview has reached the bottom so that I can load more items into it? 检测ListView何时到达底部 - onScroll()或onScrollStateChanged()? - Detect when ListView has reached the bottom - onScroll() or onScrollStateChanged()? 将textarea修复到移动设备上的页面底部(带键盘) - Fix textarea to the bottom of the page (with keyboard) on mobile devices 如何检测Horizo​​ntalScrollView已到达终点 - How to detect that the HorizontalScrollView has reached an end 如何知道listview滚动是否到达底部/顶部 - how to know if listview scroll has reached the bottom/Top Android - 我怎么知道gridview何时到达底部? - Android - how can i know when gridview has reached the bottom? 如何检测到Horizo​​ntalScrollView在Android中已结束? - How can I detect that the HorizontalScrollView has reached an end in Android? VertScrollBox检测何时到达Android和IOS - VertScrollBox Detect when bottom reached android and IOS
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM