简体   繁体   中英

Javascript Window.ScrollTop() Chrome Not Working

Im implementing an infinite scrolldown loading on my web app but somehow cannot make it work in Google Chrome, my code does work on my IE11 and Edge. Before, it was working on my google chrome but today cannot make it work and I cannot seem to trace back the changes that affected it. (or maybe my chrome settings but I already reset it back to defaults) Here's my code:

var scrollHandler = function () {
            if (hasReachedEndOfInfiniteScroll == false && ($(window).scrollTop() + $(window).height() == $(document).height())) {
                alert(1);
                loadMoreToInfiniteScrollTable(moreRowsUrl);
            }
        }

Im having problem at the ($(window).scrollTop() + $(window).height() == $(document).height()) as it never returns true when using Google Chrome.

Anyone can help me trace the issue? Thanks alot.

try using this. Try to come near bottom and then fire ajax call.

var ScrollBottom = 100;

if ($(window).scrollTop() + $(window).height() > 
    $(document).height() - ScrollBottom) { 
    loadMoreToInfiniteScrollTable(moreRowsUrl);
} 

如果您使用文档对象,它将起作用,请尝试以下操作

                           $(document).scrollTop();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM