首页 > Web开发 > 详细

网页滚动到底部,拉取数据

时间:2017-07-06 20:14:41      阅读:318      评论:0      收藏:0      [点我收藏+]

网页滚动模式

//滚到到底部自动拉取数据
        //页面滚到底部异步加载下一页数据
        $(window).scroll(function () {
            //已经滚动到上面的页面高度
            var scrollTop = parseFloat($(this).scrollTop()),
                //页面高度
                scrollHeight = $(document).height(),
                //浏览器窗口高度
                windowHeight = parseFloat($(this).height()),
                totalHeight = scrollTop + windowHeight;

            //此处是滚动条到底部时候触发的事件,在这里写要加载的数据,或者是拉动滚动条的操作
            if (scrollTop + windowHeight >= scrollHeight - 0.7) {

                var index = $(‘.swiper-slide-active‘).data("index");
                var id = $(‘.swiper-slide-active‘).attr("id");
                eval(‘‘+id+‘(‘+Number(index)+1+‘,‘+pageNumber+‘,"‘+userid+‘")‘);
            }
        });

可滚动的元素 ,滚动到底部,触发获取数据

//滚到到底部自动拉取数据
        //页面滚到底部异步加载下一页数据
        $(".swiper-slide").scroll(function () {
            //已经滚动到上面的页面高度
            var scrollTop = parseFloat($(this).scrollTop()),
                //滚动高度
                scrollHeight = this.scrollHeight,
                //窗口高度
                windowHeight = $(this).height(),
                totalHeight = scrollTop + windowHeight;
            //此处是滚动条到底部时候触发的事件,在这里写要加载的数据,或者是拉动滚动条的操作
            if (scrollTop + windowHeight >= scrollHeight - 0.7) {
                console.log("===");
                var nextIndex = Number($(‘.swiper-slide-active‘).data("index"))+1;
                var id = $(‘.swiper-slide-active‘).attr("id");
                eval(‘‘ + id + ‘(‘ + nextIndex + ‘,‘ + pageNumber + ‘,"‘ + userid + ‘")‘);
            }
        });

  

网页滚动到底部,拉取数据

原文:http://www.cnblogs.com/yanqin/p/7127644.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!