And once it hits the bottom,then have a callback function?
Asked
Active
Viewed 1.5k times
6
-
http://stackoverflow.com/questions/3962558/javascript-detect-scroll-end – Mohammad Saberi Mar 14 '12 at 07:50
-
1check this http://stackoverflow.com/questions/3962558/javascript-detect-scroll-end – Gopesh Mar 14 '12 at 07:57
-
possible duplicate of [How to check if a user has scrolled to the bottom](http://stackoverflow.com/questions/3898130/how-to-check-if-a-user-has-scrolled-to-the-bottom) – csharpfolk May 03 '14 at 06:45
1 Answers
25
You can use .scroll() event in this way on your window:
$(window).scroll(function() {
if($(window).scrollTop() + $(window).height() == $(document).height()) {
alert("bottom!");
}
});
check live demo
to detect if the user is 3/4 down the page you can try this one
$(window).scroll(function() {
if($(window).scrollTop() + $(window).height() > $(document).height() - .75*$(document).height()) {
alert("3/4th of bottom!");
}
});

Andy Novocin
- 454
- 3
- 14

Java
- 2,451
- 10
- 48
- 85
-
generally it works, but with "alert" it crashed my FF, it literally "blacked out". But I tested with console.log and it worked fine. – devnull69 Mar 14 '12 at 07:57
-
Thanks. THis works! What if I want to detect if the user is 3/4 down the page? – TIMEX Mar 14 '12 at 08:15
-
7I think your solution for 3/4 down the page is actually looking for "75 pixels from the bottom of the page". Changing `$(document).height() - 75` to `$(document).height() * 0.75` should do the trick. – sffc Jul 25 '13 at 10:23
-
1
-
This works wonderfully for me everywhere but on my mobile. If I can figure out the issue, I'll post an update. – lysdexia Aug 05 '15 at 21:25
-
Addendum: nothing wrong on phone: I was testing a lazy-loading scroll function and didn't have enough data to trigger it on the server I was testing the mobile on. Works great! – lysdexia Aug 05 '15 at 21:49