XMLHTTP 如何更好的处理无闪
<script language= "JavaScript ">
function getmsg()
{
var msg = new ActiveXObject( "Microsoft.XMLHTTP ");
msg.open( "POST ", "msg.asp?tmp= "+Math.random(),false);
msg.send();
var strmsg = unescape(msg.responseText);
window.msgbox.innerText = strmsg
}
window.setInterval( "getmsg() ",1000);
</script>
<textarea rows= "20 " name= "msgbox " cols= "70 "> </textarea>
这样处理还是会有闪烁的感觉
请高手指教
------解决方案--------------------上面的代码写错一个变量
<script language= "JavaScript ">
var strmsg1= " ";
function getmsg()
{
var msg = new ActiveXObject( "Microsoft.XMLHTTP ");
msg.open( "POST ", "msg.asp?tmp= "+Math.random(),false);
msg.send();
var strmsg = unescape(msg.responseText);
if (strmsg1==strmsg){
window.msgbox.innerText = strmsg;
strmsg1=strmsg;
}
}
window.setInterval( "getmsg() ",1000);
</script>
<textarea rows= "20 " name= "msgbox " cols= "70 "> </textarea>