JQUERY滚动加载
$(document).height():整个网页的高度
$(window).height():浏览器可视窗口的高度
$(window).scrollTop():浏览器可视窗口顶端距离网页顶端的高度(垂直偏移)
用一句话理解就是:当网页滚动条拉到最低端时,$(document).height() == $(window).height() + $(window).scrollTop()。
当网页高度不足浏览器窗口时$(document).height()返回的是$(window).height()。
$(window).scroll(function(event) { var d_height = $(document).height(); var c_height = $(window).height(); var s_height = $(document).scrollTop(); var height = $(".hd_gzbg").height() + $(".nsy_footer").height() + 200; if (d_height - c_height - s_height <= height) { if (do_submit) { do_submit = 0; $.ajax({ url:"", type:"GET", data:{}, dataType:"json", success:function(result){ if (result.errNo == 0) { do_submit = 1; page += 1; $("#id").append(html); } } }); } } });