//下拉刷新数据
获取滚动高度 获取内容高度 获取页面总高度 滚动高度+页面总高度=内容高度 就说明滚动条到底了
<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>