您的位置:首页 > 编程语言

随滚动条来加载可见屏幕内容的代码示例

2011-12-28 14:06 375 查看
$(document).ready(function() {
$(window).bind("scroll", GetData);

function GetData() {

var windowHeight = $(window).height();
var scrollHeight = $(document).scrollTop();
var screenBottom = windowHeight + scrollHeight;
var documentHeight = $(document).height();
if (screenBottom >= documentHeight) {
$(window).unbind();
$.ajax({
type: "post",
url: "GetData.aspx",
data: "action=data",
success: function(data) {
data = eval("("+ data +")");
if (data.ret =1) {
var html ="";
for (var i =0; i <12; i++) {
html +='<div style=" border:1px solid; width:198px; float:left; height:200px" >'+ i +'</div>';
}
$("#div_main").append(html);
$(window).bind("scroll", GetData);
}
}
})

}
}
});
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: