没什么技术含量,网上找的,改了一下,留着备用而已。
<div id="divContainer" style="overflow-y:auto; overflow-x:hidden; height:500px;border:0px solid red;">
<div id="divContent" style="height:750px;border:0px solid black;">
</div>
</div>
<script type="text/javascript">
window.onload = function(){
var nScrollHight = document.getElementById("divContent").offsetHeight; //滚动距离总长(注意不是滚动条的长度)
var nScrollTop = 0; //滚动到的当前位置
var nDivHight = document.getElementById("divContainer").offsetHeight; //divContainer的高度
document.getElementById("divContainer").onscroll =function(){
nScrollTop = this.scrollTop;//0~250;
nScrollHight = this.scrollHeight;//750,1000;
if(nScrollTop + nDivHight >= nScrollHight)
{
document.getElementById("divContent").style.height=1000;
alert("Scroll to Bottom, ScrollTop is:" + nScrollTop);
}
}
}
</script>