And once it hits the bottom,then have a callback function?
-
stackoverflow.com/questions/3962558/…Mohammad Saberi– Mohammad Saberi2012-03-14 07:50:53 +00:00Commented Mar 14, 2012 at 7:50
-
1check this stackoverflow.com/questions/3962558/…Gopesh– Gopesh2012-03-14 07:57:47 +00:00Commented Mar 14, 2012 at 7:57
-
possible duplicate of How to check if a user has scrolled to the bottomcsharpfolk– csharpfolk2014-05-03 06:45:26 +00:00Commented May 3, 2014 at 6:45
Add a comment
|
1 Answer
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!");
}
});
6 Comments
devnull69
generally it works, but with "alert" it crashed my FF, it literally "blacked out". But I tested with console.log and it worked fine.
TIMEX
Thanks. THis works! What if I want to detect if the user is 3/4 down the page?
sffc
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.dtc
that live demo doesnt work for me... Chrome 44.0.2403.125 if it helps)
lysdexia
This works wonderfully for me everywhere but on my mobile. If I can figure out the issue, I'll post an update.
|