简体   繁体   中英

javascript mobile crossbrowser determine if user scrolled to the bottom of page

Hello based on my question located at :

javascript crossbrowser determine if user scrolld to the bottom of page

How could i write this to be mobile compatible?

window.onscroll = function () {
if (document.body.scrollHeight == (document.body.scrollTop + document.body.clientHeight)) {
            alert("ok");
        }
    }

thank you

I do not know if this is to help.

As you say you can get the current scrollHeight, what is happen if you place a anchor on bottom of the page? and use a script as

var curr = document.body.scrollHeight;
document.location.href = "#bottompage";
if(curr == document.body.scrollHeight) {
  alert("Bottom of page");
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM