我每 3 秒更新一次聊天框并溢出 div(chatbody) 。我想要 evry 循环这个函数滚动 div 底部?
我的代码
function chat()
{
var xmlhttp;
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("chatbody").innerHTML=xmlhttp.responseText;
I THINK CODE MUST BE HERE
}
}
xmlhttp.open("GET","func/chat.php?tnow=" + (new Date()).getTime(),true);
xmlhttp.send();
}
setInterval("chat()",3000);