1
我有chatbox每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);
使用http://nodejs.org/进行聊天应用。它的好 – Imdad
你必须设置scrollTop到chatbody相等的最后一个孩子的偏移量+它的高度。 – Sergey
我想要自动滚动代码没有聊天web服务器js –