判断滚动是否到达底部

/判断是否滚动到底部
function reachBottom(){
    var scrollTop = 0;
    var clientHeight = 0;
    var scrollHeight = 0;
    if(document.documentElement && document.documentElement.scrollTop) {
            scrollTop = document.documentElement.scrollTop;
    } else if (document.body) {
    scrollTop = document.body.scrollTop;
    }
    if(document.body.clientHeight && document.documentElement.clientHeight) {
            clientHeight = (document.body.clientHeight < document.documentElement.clientHeight) ? document.body.clientHeight : document.documentElement.clientHeight;
    } else {
            clientHeight = (document.body.clientHeight > document.documentElement.clientHeight) ? document.body.clientHeight : document.documentElement.clientHeight;
    }
    scrollHeight = Math.max(document.body.scrollHeight,document.documentElement.scrollHeight);
    if(scrollTop + clientHeight >= scrollHeight) {
            return true;
    } else {
            return false;
    }
}

ios用window获取对象

posted @ 2016-08-11 10:11  djdliu  阅读(221)  评论(0编辑  收藏  举报