每天积累一点,才会成长......

如何用js控件div的滚动条,让它在内容更新时自动滚到底部?

<script language="javascript">
function sendText()
{
var e=document.getElementById("div1")
var inp=document.getElementById("inp")
e.innerText=e.innerText+"\n"+inp.value;
//e.scrollTop=e.scrollHeight;
}
function sc()
{
var e=document.getElementById("div1")
e.scrollTop=e.scrollHeight;
}
var s=setInterval("sc()",200)
</script>
<div id="div1" style="border:1px #ff9966 dashed;width:400;height:100;overflow-x:hidden;overflow-y:scroll">
</div>
<input type="text" id="inp" style="width:300">
<input type="button" onclick="sendText()" value="发送">

posted on 2008-11-14 16:17  wenbo  阅读(853)  评论(0编辑  收藏  举报