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 @ 2010-11-17 15:46  西游  阅读(14915)  评论(4编辑  收藏  举报