问题
I am trying to implement infinite scroll on my website and it works well on browsers on any computer, but it has issues on mobile browsers. So far, on chrome, if I don't zoom in or out it works ok but once I zoom either way it stops working. On safari it doesn't work at all. This is the code that I am using:
$(window).on('scroll', function (e) {
console.log(" window.scrollTop = " + $(window).scrollTop() + " document.height=" + $(document).height() + " window.height =" + $(window).height());
if ($(window).scrollTop() == $(document).height() - $(window).height()) {
load();
}
});
If anyone has any suggestions please let me know.
回答1:
Instead of using
$(window).height()
try using
window.innerHeight
来源:https://stackoverflow.com/questions/20619264/infinite-scroll-on-mobile-browsers