Good day to everyone, I encountered such a trifle: how to determine on js / jquery that the user reached the bottom of the page? Something does not occur to anything ... I wanted to define using $ (window) .offset (), but this method does not apply to this object ...
Connoisseurs, tell me! Thank you in advance :)

    3 answers 3

    Your question is related to this . Try this:

    $(window).scroll(function() { if ($(window).scrollTop() == $(document).height() - $(window).height()) { //Пользователь долистал до низа страницы } }); 

      In order to determine by how many pixels a document is scrolled, you need to refer to the scrollTop and scrollLeft properties of the document.documentElement object if the browser is in the following standards mode, or document.body if the browser is in quirks mode.

       var html = document.documentElement; alert("Вы уже прокрутили "+ html.scrollTop +"px этой страницы"); 

      You define the height of the Body and see if the html.scrollTop is equal to it.

        And if through $(document.body).offset() и $(window).height() ?

        Like that:

         if($(document.body).offset().top + $(window).height() == $(document.body).height()){ //blablabla, только не так грубо - я показал лишь принцип } 
        • $(document.body).offset().top; always returns 0. $ (window) .height (); $ (document.body) .height (); Always constant. Those. looking for another solution ... - metazet
        • Fie you, for sure). offset () returns the coordinates of the upper left corner. It is necessary through $ (document.body) .scrollTop. > always constant. And if you resize a window? - ling