5

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

Govind
  • 979
  • 4
  • 14
  • 45
Val Do
  • 2,695
  • 4
  • 20
  • 35

3 Answers3

6

Try:

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

DEMO

laaposto
  • 11,835
  • 15
  • 54
  • 71
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
  • 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
  • 979
  • 4
  • 14
  • 45