下面是一个简单的聊天程序配合ajax做的,现在是一发信息,ie窗口就会弹出一次,请问这个在哪里取消呢小弟对js不熟悉。。请指点<script>
function quitroom()
{
if(confirm("お帰りですか?"))
{
var ajax = createAJAX();
ajax.open('POST','<?php echo basename(__FILE__);?>',0);
ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
ajax.send("action=quit&name="+encode($('chat_user').value));
//alert("sending close  action=quit&name="+encode($('chat_user').value));
//alert("response:"+ajax.responseText);
}
else return '';
}setInterval(" load_word()",(debug)?6000:1000);var load_word_ajax;//下载完成后的处理函数
function load_word_change()
{
if (load_word_ajax.readyState == 4)
{
if (load_word_ajax.status != 200)
{
load_word_error();
return;
}
window.loading = false;
var body = $('div_contents'); try {
if (debug) alert(load_word_ajax.responseText);
eval("var arr = "+load_word_ajax.responseText); 
} catch(e)
{
alert('Error 101\nJSON syntax error!\n\n'+load_word_ajax.responseText);
return;
}
if (!arr || !arr.lastmod || typeof(arr.lastmod) == "undefined" )
{
return;
} var html = "";
var line = arr.lines;
var i = 0;
var v1 = 0;
var div_online = $('div_online');
if (window.first)
{
body.innerHTML = "";
window.first = false;
}

if (arr.onlines)
{
$('div_online').innerHTML = "";
for(var i=0;i<arr.onlines.length;i++) addonline(arr.onlines[i]);
}
for(var i=0;i<line.length;i++)
{
var linekey = line[i].word.substring(line[i].word.length-20,line[i].word.length)+line[i].time;
if (window.loaded_lines[linekey] === true)
{
if (debug) alert("jump:"+linekey);
continue;
}
var div1 = document.createElement("div");
window.nowdisplay ++;
if (window.nowdisplay > window.maxdisplay) window.nowdisplay = 1;
if ($("contentitem"+window.nowdisplay)) body.removeChild($("contentitem"+window.nowdisplay));
div1.className = "content";
div1.id = "contentitem"+window.nowdisplay;
div1.innerHTML = line[i].word+" <span class='time'>("+line[i].time+")</span>";
body.appendChild(div1);

window.loaded_lines[linekey] = true;
body.scrollTop = 655350;
v1 = 1;
} if (v1) 
{
window.focus(); 
document.body.focus();
window.lastmod = arr.lastmod;
if(debug) alert("lastmod = "+arr.lastmod + " \nwindow.lastmod="+window.lastmod);
if ($('chat_word').disabled == false) $('chat_word').focus();
}
}
}function load_word_error()
{
window.loading = false;
window.status = 'Error 102:while loading words';
setTimeout("window.status = '';",5000);
}function load_word()
{
load_word_ajax = createAJAX();
if (window.loading)
{
try
{
load_word_ajax.abort();
window.loading = false;
}catch(e) {}
}
if (!window.lastmod)
{
alert("window.lastmod="+window.lastmod);
return;
}

load_word_ajax.open('POST','<?php echo basename(__FILE__);?>',true);
load_word_ajax.onreadystatechange = load_word_change;

var urlstring = '';
urlstring += "lastmod="+window.lastmod;
urlstring+= "&room="+room;
urlstring+= "&action=read";
urlstring+= "&name="+encode($('chat_user').value);

if (window.first)
{
urlstring+= "&first=true";
urlstring += "&dis="+dis;
}
//如果到了取得在线用户的时间
if (window.dotouch) 
{
urlstring+= "&touchme=true";
window.dotouch = false;
//垃圾内存回收
try { CollectGarbage(); } catch(e) {}
} window.loading = true;
if (debug) alert("sending:"+urlstring);
load_word_ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");

load_word_ajax.send(urlstring);
}function touchme()
{
window.dotouch = true;
setTimeout("touchme()",window.touchs*1000);
}function showalert(a,n)
{
if (!n) n=0;
if (n>3) return;
if (!a)
{
a = 0;
b = 1;
}
else
{
a = 1;
b = 0;
}
document.title = mytitle[a];
setTimeout("showalert("+b+","+(n+1)+");",500);
}function addonline(name)
{
if ($(name)) return;
var d1 = document.createElement("div");
d1.id = name;
d1.innerHTML = name;
d1.className = "online";
$('div_online').appendChild(d1);
}touchme();function check_send(e)
{
if (!e) e = window.event;
var obj = $('chat_word');
if (isIE) obj.style.height = obj.scrollHeight+3;
if (e.keyCode == 13)
{
if ((!e.shiftKey && !e.altKey && !e.ctrlKey) || !isIE)
{
chat_send();
obj.style.height = 20;
return false;
}
else if (isIE) obj.style.height = obj.scrollHeight+18;
}
return true;
}var send_ajax;
send_ajax_change  = function()
{
if (send_ajax.readyState == 4)
{
if (send_ajax.status != 200)
{
send_ajax_error();
return;
}
if (debug) alert("send_ajax response:"+send_ajax.responseText);
if (send_ajax.responseText.indexOf("NAME")!=-1)
{
alert('お名前使われましたよ');
$('chat_user').value = "";
$('chat_user').focus();
}
else if (send_ajax.responseText.indexOf("repeat")!=-1)
{
$('chat_word').value = window.lastcontent;
}

on_send_ok();

if (!window.loading)
{
window.dotouch = true;
load_word();
}
}
}function on_send_begin()
{
with($('chat_word'))
{
disabled = true;
style.backgroundColor = "#eeeeee";
}
window.sending = 1;
}function on_send_ok()
{
window.sending = 0;
with($('chat_word'))
{
value = '';
disabled = false;
focus();
style.backgroundColor = "#ffffff";
}
}function on_send_error()
{
window.sending = 0;
with($('chat_word'))
{
disabled = false;
focus();
style.backgroundColor = "#ffffff";
}
}function send_ajax_error()
{
alert('Error 103\nwhen send words\n\nYou can send them again!');
$('chat_word').value = window.lastcontent;
window.sending = 0;
on_send_error();
}function chat_send()
{
send_ajax = createAJAX();
send_ajax.open('POST','<?php echo basename(__FILE__);?>',true);
send_ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
send_ajax.onreadystatechange = send_ajax_change;
var urlstring = '';
var name = $('chat_user').value.replace("\n","");
var content = $('chat_word').value; 
var bold = ($('input_bold').checked)?"bold":"";
var size = parseInt($('input_size').value);
var font = $('input_font').value;

if (name == "")
{
alert('Please enter your nick name first!!');
$('chat_user').focus();
return;
}

if (content == "" || content == "\n" || content == "\n\n" || content == "\n\n\n")
{
alert('Please enter your words!');
$('chat_word').focus();
$('chat_word').value = "";
return;
}
if (size>100) size = 100;
else if (size<0) size = 1;

urlstring+= "action=write";
urlstring+= "&name="+encode(name);
urlstring+= "&content="+encode(content);
urlstring+= "&bold="+bold;
urlstring+= "&color="+window.color;
urlstring+= "&size="+size;
urlstring+= "&font="+font;
urlstring+= "&room="+room; window.sending = 1;
window.lastcontent = content;
on_send_begin();
if (debug) alert("sending:"+urlstring);

send_ajax.send(urlstring);
setTimeout("if (window.sending) send_ajax.abort(); on_send_error();",5000);
setCookie("chatusername",$('chat_user').value);
}function resize(s)
{
var o = $('div_contents').style;
var h = parseInt(o.height);
h = (s)?h+50:h-50;
if (h<=50 || h>=3000) return;
o.height = h;
$('div_contents').scrollTop = 655350;
}function clearAll()
{
$('div_contents').innerHTML = "";
}</script>