<script type="text/javascript">
//当窗口滚动到一定高度时 某块页面开始加载数据
window.onload = function()
{
var oHeader = document.getElementById("header");
var height = oHeader.offsetHeight;

window.onscroll = function(){
//scrollTop的值
var scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
//窗口可视化高度
var clientHeight = document.documentElement.clientHeight || document.body.clientHeight;
document.getElementById("txt1").value="scrollTop:"+scrollTop+",height:"+height;
var oContent = document.getElementById("content");

if(scrollTop+clientHeight >height)
{
oContent.innerHTML = "<h1>正在加载中.....</h1>";

//延迟3秒执行
setTimeout(function(){
oContent.innerHTML = "<h1>scroll事件执行的代码块</h1>";
oContent.style.background="red";
},3000);

}
else
{
oContent.innerHTML="";
oContent.removeAttribute("style");
}
}
}
</script>