html页面下拉刷新数据


//下拉刷新数据
获取滚动高度  获取内容高度 获取页面总高度   滚动高度+页面总高度=内容高度 就说明滚动条到底了

<script type="text/javascript">
/********************
* 取窗口滚动条高度 
******************/
function getScrollTop()
{
    var scrollTop=0;
    if(document.documentElement&&document.documentElement.scrollTop)
    {
        scrollTop=document.documentElement.scrollTop;
    }
    else if(document.body)
    {
        scrollTop=document.body.scrollTop;
    }
    return scrollTop;
}
/********************
* 取窗口可视范围的高度 
*******************/
function getClientHeight()
{
    var clientHeight=0;
    if(document.body.clientHeight&&document.documentElement.clientHeight)
    {
        var clientHeight = (document.body.clientHeight<document.documentElement.clientHeight)?document.body.clientHeight:document.documentElement.clientHeight;        
    }
    else
    {
        var clientHeight = (document.body.clientHeight>document.documentElement.clientHeight)?document.body.clientHeight:document.documentElement.clientHeight;    
    }
    return clientHeight;
}
/********************
* 取文档内容实际高度 
*******************/
function getScrollHeight()
{
    return Math.max(document.body.scrollHeight,document.documentElement.scrollHeight);
}
window.onscroll = function (){
    if (getScrollTop()+getClientHeight()==getScrollHeight()){
        var listRows=$("#listRows").val();
          $.post("__URL__/getIndexGoods",{listRows:listRows},function(data){
              var dataobj=eval("("+data+")");
              $("#listRows").val(dataobj.listRows);
              if(dataobj.goodsList.length>0){
                  var html="";
                    for(var val in dataobj.goodsList){
                        html+="<div class='hot_prod_list'>";
                            html+="<div class='box pos_rel'>";
                                html+="<img src='__PUBLIC__/updateimg/Goods/"+dataobj.goodsList[val].goods_home+"'>";
                                html+="<h4><a href=''>"+dataobj.goodsList[val].goods_name+"</a></h4>";
                                html+="<div class='price'><span class='red new'>¥<i>"+dataobj.goodsList[val].goods_price+"</i></span><span class='old'>¥<i>"+dataobj.goodsList[val].goods_market+"</i></span></div>";
                                html+="<a href='__URL__/getGoods?goodsid="+dataobj.goodsList[val].goods_id+"' class='btn_buy red pos_abs'>立即抢购</a>";
                            html+="</div>";
                        html+="</div>";
                    }
                    $("#ulcontent").append(html);
              }else{
                    $("#buttomDiv").html("-以没有更多商品-");
                    $("#buttomDiv").removeClass("scrollExtend-loading");
              }
          });
         }
    }
</script>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值