Reputation: 2560
I am trying to check when user reach the bottom of browser and I use the following:
var scrollHeight = $(document).height();
var scrollPosition = $(window).height() + $(window).scrollTop();
if ((scrollHeight - scrollPosition) / scrollHeight === 0) {
alert();
}
When I test it on desktop and also chrome emulator it works fine but on real phone(both android and IOS) it does not work.
Is there any better way to detect the end of scrolls on phones?
Upvotes: 0
Views: 53
Reputation: 3723
You can try this:
window.onscroll = function(ev) {
if ((window.innerHeight + window.pageYOffset) >= document.body.offsetHeight) {
alert("you're at the bottom of the page");
}
};
Upvotes: 2