当前位置: 代码迷 >> 综合 >> jQuery实现滚动条动态加载
  详细解决方案

jQuery实现滚动条动态加载

热度:62   发布时间:2023-11-03 04:44:11.0
//滚动条加载底部自动加载
$(function(){//鼠标滚动事件
    $(window).scroll(function(){console.log("滚动条到顶部的垂直高度:" +  $(window).scrollTop() );
        console.log("页面的文档高度:" +  $(document).height() );
        console.log("浏览器的高度:" +  $(window).height() );
//下面这句主要是获取网页的总高度,主要是考虑兼容性所以把Ie支持的documentElement也写了,这个方法至少支持IE8
        var htmlHeight=document.body.scrollHeight||document.documentElement.scrollHeight;
        //clientHeight是网页在浏览器中的可视高度,
        var clientHeight=document.body.clientHeight||document.documentElement.clientHeight;
        //scrollTop是浏览器滚动条的top位置,
        var scrollTop=document.body.scrollTop||document.documentElement.scrollTop;
        //通过判断滚动条的top位置与可视网页之和与整个网页的高度是否相等来决定是否加载内容;
        if(scrollTop+clientHeight==htmlHeight){start+=length;
            findBookList(start,length);
            // 延时
             // setTimeout(function () {
             //
             // },1000)

        }})
  相关解决方案