js 下滑翻页兼容wap

    $(window).scroll(function() {
        var htmlHeight = document.body.scrollHeight || document.documentElement.scrollHeight;
        // var clientHeight = document.documentElement.clientHeight; //window.screen.height 
        //pc可以用上面的,wap端为了兼容浏览器用下面的
        var clientHeight = window.screen.height; //window.screen.height
        var scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
        if (parseInt(scrollTop + clientHeight + 1) >= htmlHeight) {
            page = typeof($('#page').val()) == 'undefined' ? 1 : $('#page').val();
            page == 1 ? page = 2 : '';
            preList(page);//这里面写翻页处理
        }
    });

你可能感兴趣的:(js 下滑翻页兼容wap)