jquery实现上拉加载

$(window).scroll(function() {
      var scrollTop = $(this).scrollTop(); //滚动条距离顶部的高度
      var scrollHeight = $(document).height(); //当前页面的总高度
      var clientHeight = $(this).height(); //当前可视的页面高度
      if (scrollTop + clientHeight >= scrollHeight - 50) {
         getData(); // 请求数据
      }
})  
window.onscroll = function() {      //获取被卷去高度      var scrollTop = document.body.scrollTop;      //获取窗口高度(可见区域高度)      var windowHeight = document.documentElement.clientHeight;      //获取文档高度      var documentHeight = document.body.scrollHeight;      if (scrollTop + windowHeight >= documentHeight - 50) {            $('#nomore').show();          //发送Ajax请求获取分页数据      }}
/**
 * 得到浏览器显示的屏幕高度
 */  
function getViewHeight() {
    if (window.innerHeight != window.undefined)
        return window.innerHeight;
    if (document.compatMode == 'CSS1Compat')
        return document.documentElement.clientHeight;
    if (document.body)
        return document.body.clientHeight;
    return window.undefined;
}

/**
 * 得到浏览器显示的屏幕宽度
 */
function getViewWidth() {
    if (window.innerWidth != window.undefined)
        return window.innerWidth;
    if (document.compatMode == 'CSS1Compat')
        return document.documentElement.clientWidth;
    if (document.body)
        return document.body.clientWidth;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值