XMLHTTP+javascript+Asp写得聊天室,无刷新实现。原创代码放送!服务器支持Asp即可使用(六)

发表于:2007-06-30来源:作者:点击数: 标签:
#############续send.asp################# var oRDom=new ActiveXObject(Microsoft.XMLDOM); oRDom.async=false; var Path=reload.asp; var tCok; function Clock() {cRld++; if (cRld10){cRld=1;GetXmlData();} clearTimeout(tCok); tCok=setTimeout(Clock(
#############续send.asp#################

var oRDom=new ActiveXObject("Microsoft.XMLDOM");
    oRDom.async=false;
var Path="reload.asp";
var tCok;
function Clock()
{cRld++;
if (cRld>10){cRld=1;GetXmlData();}
clearTimeout(tCok);
tCok=setTimeout("Clock()",1000);
}   
function GetXmlData() //这就是刷新用户XML数据的函数
{cRld=1;
   oRDom.load(Path)
    if(oRDom.parseError.errorCode != 0)
      {alert("Sorry.出现了错误");
       return }
    else
     {
  var aryF=oRDom.documentElement.selectNodes("F");
  var aryT=oRDom.documentElement.selectNodes("T");
  var arysC=oRDom.documentElement.selectNodes("sC");
  var arycL=oRDom.documentElement.selectNodes("cL");
  var arysJ=oRDom.documentElement.selectNodes("sJ");
  var aryE=oRDom.documentElement.selectNodes("E");
  var tmpHtml="";
  lengt=aryF.length;
  for(var i=0;i<lengt;i++){
            img="<img src=girl.gif width=12 height=12 border=0>";
            tmpHtml="<font style=\‘’cursor:hand;color:"+arycL(i).text+"\‘’>"+eV[aryE(i).text*2]+rp2(arysC(i).text,"{^amp]","&")+"</font>  <span class=t>["+arysJ(i).text+"]</span><br>";
            tmpHtml=rp2(tmpHtml,"$F","<a href=\"javascript:parent.sd.towho(‘’"+aryF(i).text+"‘’);\">"+img+aryF(i).text+"</a>");
            tmpHtml=rp2(tmpHtml,"$T","<a href=\"javascript:parent.sd.towho(‘’"+aryT(i).text+"‘’);\">"+aryT(i).text+"</a>");
            if (aryF(i).text==Me || aryT(i).text==Me)
           { parent.my.Ly.innerHTML+=tmpHtml;
            } else
             parent.pub.Ly.innerHTML+=tmpHtml;
            }
}
delete(aryF);delete(aryT);delete(arysC);delete(arycL);delete(arysJ);
}
function towho(un){
document.say.T.options[0].value=un;
document.say.T.options[0].text=un;
document.say.says.focus();return;}
</script>
<base onmouseover="parent.window.status=‘’欢迎光临 蓝蝶精品网 www.ChinaOk.net 站长:NetNice  QICQ:6097356 ‘’;return true;">
</head>
<body bgcolor="#76b4d9" topmargin="4" leftmargin="1"  >
<table BORDER="0"  width="767"  cellspacing="0" cellpadding="0" >
<tr><td  width="735" height="16" align="left" nowrap>
<form  method="post" action="save.asp" name="say" target="b" onsubmit=‘’return(checksays());‘’>
<input type="hidden" name="oldsays" >
<input name="F" maxlength="10" size="10" value="<%=session("u_name")%>" readonly style="BACKGROUND-COLOR: #76aadd; BORDER-BOTTOM: 0px double; BORDER-LEFT: 0px double; BORDER-RIGHT: 0px double; BORDER-TOP: 0px double; COLOR: #ffffff; TEXT-ALIGN: right">
 对 <select name="T" onclick="this.options[0].value=‘’大家‘’; document.say.T.options[0].text=‘’大家‘’; document.say.says.focus();" >                
<option value="大家" selected>大家</option>                
</select> 说:<input type=text name="says"  maxlength="150" size="50" style="BACKGROUND-COLOR: #ffffff; BORDER-BOTTOM: 1px double; BORDER-LEFT: 1px double; BORDER-RIGHT: 1px double; BORDER-TOP: 1px double; COLOR: #000000" aclearcase/" target="_blank" >ccesskey="t" title="发表对话区(Alt+T)可激活!" LANGUAGE="javascript ">               
 <input type="submit" name="send" value="发言" class="an" accesskey="s" onmouseover="this.style.color=‘’3366dd‘’" onmouseout="this.style.color=‘’663300‘’" title="(Alt+S)">               
</form></td></tr></table>                      
<div style="HEIGHT: 80px; LEFT: 15px; POSITION: absolute; TOP: 30px; WIDTH: 600px">            
<form name="oT">                      
  <table BORDER="0"  width="600"  cellspacing="0" cellpadding="0">                        
    <tr>                                
      <td  width="160" height="16" align="center" nowrap valign="top">
<input accesskey="a" type="checkbox" name="as" checked onclick="parent.pub.scrollit();parent.my.scrollit();document.say.says.focus();"><A  onclick=moveself(); title=" “激活/禁止”对话区自动滚屏(Alt+A)!">滚屏</A>          
      
</td>   
    <td  width="230" height="16" align="left" nowrap valign="top">                  <span  title=" 改变你的发言的字体颜色(Alt+F)!">
 <select name=usercolor accesskey="f" onchange="document.say.says.style.color=this.options[this.selectedIndex].value;">                           
<OPTION selected style="COLOR: #000000" value="000000">默认颜色</OPTION>
<OPTION style="COLOR: #000000" value="#000000">黑色沉静</OPTION>                                  
<option style="COLOR: #ff0000" value=‘’#FF0000‘’>红色热情</option>                         
<option style="COLOR: #0000ff" value=‘’#0000FF‘’>蓝色开朗</option>                         
<option style="COLOR: #ff00ff" value=‘’#FF00FF‘’>桃色浪漫</option>                         
<option style="COLOR: #009900" value=‘’#009900‘’>绿色青春</option>                         
<option style="COLOR: #009999" value=‘’#009999‘’>青色清爽</option>                         
<option style="COLOR: #990099" value=‘’#990099‘’>紫色拘谨</option>                        
<option style="COLOR: #990000" value=‘’#990000‘’>暗夜兴奋</option>                         
<option style="COLOR: #000099" value=‘’#000099‘’>深蓝忧郁</option>                         
<option style="COLOR: #999900" value=‘’#999900‘’>卡其制服</option>                         
<option style="COLOR: #ff9900" value=‘’#FF9900‘’>镏金岁月</option>                         
<option style="COLOR: #0099ff" value=‘’#0099FF‘’>湖波荡漾</option>                         
<option style="COLOR: #9900ff" value=‘’#9900FF‘’>发亮蓝紫</option>                         
<option style="COLOR: #ff0099" value=‘’#FF0099‘’>爱的暗示</option>                         
<option style="COLOR: #006600" value=‘’#006600‘’>墨绿深沉</option>                         
<option style="COLOR: #333333" value=‘’#333333‘’>灰色轨迹</option>                         
<option style="COLOR: #999999" value=‘’#999999‘’>伦敦灰雾</option>                         
</select></span>                           
<span title=" 改变您的说话时的表情(Alt+Q)!" ><select accesskey="q"  name=userface style="FONT-SIZE: 9pt;width:65px" size="1">
<script language="Javascript">
for(var iF=0;iF<eV.length;iF+=2)
{document.writeln("<option value=\""+eV[iF]+"\">"+eV[iF+1]);
}
</script>
</select></span> <input TYPE="checkbox" name="ws" id="ws" accesskey="m" ><A   title=" 和聊友说句悄悄话(Alt+M)!"><label for=ws >私聊</label></A> </td>
<td  width="250" height="16"  align="left" nowrap valign="top">
   <INPUT id=clock name=clock type=button value=1200 class="an" title="如果您长时间不发言(潜水),请注意:当计数器减至零时,您将被被踢出!" style="color:#ff3300;width:60;" disabled>                                            
</td>                              
</tr>                                  
</table>  </form>                 
  </div>                       
  <script>                          
write();
GetXmlData();
Clock();                       
</script>       
  </body>                                  
</html>                                  

原文转自:http://www.ltesting.net