6

And once it hits the bottom,then have a callback function?

3

1 Answer 1

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!");
   }
});
Sign up to request clarification or add additional context in comments.

6 Comments

generally it works, but with "alert" it crashed my FF, it literally "blacked out". But I tested with console.log and it worked fine.
Thanks. THis works! What if I want to detect if the user is 3/4 down the page?
I 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.
that live demo doesnt work for me... Chrome 44.0.2403.125 if it helps)
This works wonderfully for me everywhere but on my mobile. If I can figure out the issue, I'll post an update.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.