There is this kind of code:

$(window).scroll(function(){ if ($(window).scrollTop() == $(document).height() - $(window).height()) alert('Привет'); }); 

Works great on the desktop. But for some reason it does not work in the mobile version.
I only have iPhone 5C mobile phones, so the devices for the test are not great, but in the imitation mode of mobile phones in Chrome, the code also does not want to be executed.
Is there a non-kolkhoz and crutches-free version? Do you want to track the end of page by scrolling?

    1 answer 1

    Try this option using the James Padolsey cross-browser document height detection feature :

     function getDocHeight() { var D = document; return Math.max( D.body.scrollHeight, D.documentElement.scrollHeight, D.body.offsetHeight, D.documentElement.offsetHeight, D.body.clientHeight, D.documentElement.clientHeight ); } $(document).ready(function() { $(window).scroll(function() { if ($(window).scrollTop() + $(window).height() == getDocHeight()) { alert("Конец страницы"); } }); }); 
     #container { height: 1000px; width: 100px; background-color: red; } 
     <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div id="container"></div>