4

hello I need when $(window) is scrolled down with 100% alert something how can I do it?

Govind
  • 939
  • 4
  • 14
  • 43
Val Do
  • 2,605
  • 4
  • 17
  • 33

3 Answers3

5

Try:

$(window).scroll(function() {
   if($(window).scrollTop() + $(window).height() == $(document).height()) {
       alert("END!");
   }
});

DEMO

laaposto
  • 11,377
  • 15
  • 52
  • 68
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
  • 4,517
  • 10
  • 67
  • 132
  • 2
    as 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
  • Does window and document keywords belong to WebAPI or HTML or Jquery? – sofs1 Apr 06 '18 at 12:05
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
  • 939
  • 4
  • 14
  • 43