hello I need when $(window)
is scrolled down with 100%
alert something
how can I do it?
Asked
Active
Viewed 2.8k times
3 Answers
6
Try:
$(window).scroll(function() {
if($(window).scrollTop() + $(window).height() == $(document).height()) {
alert("END!");
}
});

laaposto
- 11,835
- 15
- 54
- 71
-
why it is not working, what browser you use? can you post code which you tried? – Govind Aug 20 '14 at 08:38
-
@valkharitonashvili What do you mean not working? Message is not alerted at all? – laaposto Aug 20 '14 at 08:51
-
4
I used something like this once :)
if($(window).scrollTop() + $(window).height() > $(document).height() - 50) {
//alert
}
Just play with the numbers, this one is built to pop out the alert just almost before the end of the scroll

Imnotapotato
- 5,308
- 13
- 80
- 147
-
2as explained, this one shows alert 50px before the end of the page. I pasted it here because I find it very useful in a lot of things, and it uses the consept of the main question here. I used it when developing a blog with a "load more posts" button automatically when it scrolls almost to the bottom of the page. – Imnotapotato Aug 20 '14 at 08:11
-
3
Try this one, When you scroll the page and if the page is reached to bottom, then alert message will get displayed.
$(window).scroll(function() {
if($(window).scrollTop() + $(window).height() == $(document).height()) {
alert("Bottom Reached!");
}
});

Govind
- 979
- 4
- 14
- 45