XMLHTTP+Javascript+Asp写得聊天室,无刷新实现(五)
文章类别:
asp | 发表日期:2008-10-5 20:40:40
这是最重要的一个了。也很大。我的习惯不太好。没有加详细的注释,认真看吧。
#########send.asp##############
<html>
<head>
<META content="text/html; charset=gb2312" http-equiv=Content-Type>
<meta http-equiv='pragma' content='no-cache'>
<link REL="SHORTCUTICON" url="images/Bluenote.ico">
<style type="text/css">
td{font-family: "宋体"; font-size: 9pt}
body { font-family: "宋体"; font-size: 9pt}
select { font-family: "宋体"; font-size: 9pt}
.p9{font-family:"宋体";font-size:9pt;line-height:130%; width:68px;}
A {cursor:hand;text-decoration:none; font-family: "宋体"; font-size: 9pt;}
input{font-size:9pt}
.an{background-color:FFFFFF;color:000000;border: 1 double}
</style>
<title>发言</title>
<script Language=JavaScript>
var tmp0="$F对$T说:|无表情|$F向$T微微一笑:|微笑|$F笑嘻嘻地对$T说:|嘻笑|$F冲$T傻乎乎的笑笑:|傻笑|$F对$T娇笑着:|娇笑|$F对着$T哈哈大笑:|大笑|$F看着$T,心头一阵狂喜:|狂喜|$F冲着$T狂笑不已:|狂笑|$F对$T奸笑着:|奸笑|$F咯咯一笑,很大方地对$T说:|大方|$F紧紧地握住$T的手:|握手|$F向$T挥了挥手:|挥手|$F耸耸肩,两手一摊:$T,|耸肩1|$F无奈地耸耸肩:$T,|耸肩2|$F摸摸$T的头,细声安慰:|安慰|$F笑呵呵向$T一拱手:|拱手|$F很有礼貌地对$T作了一揖:|作揖|$F深深地鞠了一躬:$T,|鞠躬|$F不好意思地对$T说:|歉意|$F瞪大了眼睛,很讶异地看着$T:|讶异|$F大吃一惊:$T,|惊讶|$F茫然地看着$T:|茫然|$F一脸的迷茫:$T,|迷茫|$F颇感迷惑:$T,|迷惑|$F感到很是奇特:$T,|奇特|$F对$T潇洒地一甩头:|潇洒|$F惋惜地看着$T:|惋惜|$F对$T皱了皱眉:|皱眉|$F很遗憾地对$T说:|遗憾|$F大包大揽地向$T承诺:|承诺|$F抓抓头皮,还是不解:$T,|不解|$F提高嗓门,大声地对$T说:|大声|"
var tmp1="$F不解地问$T:|询问|$F向$T吐了吐舌头:|吐舌|$F非常自信地对$T说:|自信|$F向上天祈祷着,$T,|祈祷|$F向$T噘了噘嘴:|噘嘴|$F嘟着嘴对$T说:|嘟嘴|$F平静地对$T说:|平静|$F高兴地对$T说:|高兴|$F在$T耳边悄悄地说:|耳语|$F眯着小眼睛对$T说:|眯眼|$F眼波晶莹明亮地看着$T:|眼亮|$F幸福地看着$T:|幸福|$F很满足地对$T说:|满足|$F轻轻牵着$T的手,小声地说:|牵手|$F轻轻推了$T一下:|轻推|$F粘粘糊糊地向$T撒娇:|撒娇|$F对$T做了个鬼脸:|鬼脸|$F神秘兮兮地对$T说:|神秘|$F脸上泛起了红晕,低着头小声地对$T说:|脸红|$F低着头,玩弄着自己的手指,羞得满脸通红:$T,|害羞|$F小猫猫般地依偎在$T的怀中:|依偎|$F拍了拍$T那脏兮兮的小脸蛋:|拍脸|$F向$T抛去一个媚眼:|媚眼|$F恶狠狠地冲$T瞪着眼睛:|瞪眼|$F柔声地对$T说:|柔声|$F情意绵绵地望着$T说:|深情|$F温柔地抱住$T说:|拥抱|$F亲了亲$T的脸:|亲亲|$F恋恋不舍地拉着$T的衣角:|不舍|"
var tmp2="$F运足气一声断喝:$T!|断喝|$F幸灾乐祸地对$T说:|幸灾|$F露出无可奈何的表情:$T,|无奈|$F使劲敲敲自己脑门,看着$T:|拍脑|$F顾作沉思状:$T,|沉思|$F一付无辜的样子:$T,|无辜1|$F感到非常无辜,$T:|无辜2|$F感觉很不舒服:$T,|不适|$F打个大哈欠:$T,|哈欠|$F口吐白沫,晕倒在地:$T,|白沫|$F感到无聊极了:$T,|无聊|$F看着$T,快要吐了:|想吐|$F一脸无赖泼皮样子:$T,|无赖|$F歪着看着$T,二球劲十足:|二球|$F双眼盯着$T,奴才嘴脸十足:|奴才|$F委屈地对$T说:|委屈|$F大感沮丧:$T,|沮丧|$F望着窗外细雨淅淅,不由得双眼朦胧:$T,|伤感|$F悲伤地对$T说:|悲伤|$F泪水在眼框里打着转:$T,|含泪|$F看着$T,快要哭了:|要哭|$F低低抽泣着:$T,|抽泣|$F一把将$T抱住,哭哭涕涕:|抱哭|$F想到伤心处,泪流如注:$T,|大哭|$F抱头放声大哭:$T,|痛哭|$F号淘大哭:$T,|大哭|$F对$T露出失望的表情:|失望|$F用眼角斜视$T,满脸俱是轻蔑不屑之色:|轻蔑|$F生气地对$T说:|生气|"
var tmp3="$F向$T提出强烈抗议:|抗议|$F对$T大声叫嚷:|叫嚷|$F对$T气愤地嚷道|气愤|$F怨毒地看着$T:|怨毒|$F一把甩掉$T的手,恶恨恨地说:|甩手|$F目光尽赤,冲$T怒不可恶地狂吼:|暴怒|$F打了$T老大一个耳括子:|耳光|$F不客气地猛揍$T一拳:|拳打|$F一脚踢在$T的屁股上:|脚踢|$F向$T点头称是:|点头称是|$F兴高采烈地对$T说:|兴高采烈|$F惊慌失措地对$T说:|惊慌失措|$F幸灾乐祸地对$T说:|幸灾乐祸|$F眉飞色舞地对$T说:|眉飞色舞|$F阴阳怪气地对$T说:|阴阳怪气|$F哭天抢地地对$T说:|哭天抢地|$F牢骚满腹地对$T说:|牢骚满腹|$F理屈词穷地对$T说:|理屈词穷|$F江郎才尽地对$T说:|江郎才尽|$F凶神恶煞地对$T说:|凶神恶煞|$F眉歪眼斜地对$T说:|眉歪眼斜|$F目光凛然地对$T说:|目光凛然|$F声嘶力竭地对$T说:|声嘶力竭|$F意乱情迷地对$T说:|意乱情迷|$F脸色铁青地对$T说:|脸色铁青|$F失魂落魄地对$T说:|失魂落魄|$F目光呆滞地对$T说:|目光呆滞|$F正气凛然地对$T说:|正气凛然|"
var tmp4="$F手足无措地对$T说:|手足无措|$F无精打采地对$T说:|无精打采|$F依依不舍地对$T说:|依依不舍|$F拳打脚踢地对$T说:|拳打脚踢|$F不怀好意地对$T说:|不怀好意|$F毛手毛脚地对$T说:|毛手毛脚|$F得意洋洋地对$T说:|得意洋洋|$F慨叹万千地对$T说:|慨叹万千"
var etmp=tmp0+tmp1+tmp2+tmp3+tmp4;
var eV=etmp.split("|")
function wh(fn){
fn.open();
fn.writeln("<!--★请另存为HTML类型的文件★-->");
fn.writeln("<html><head><title>对话区</title><meta http-equiv=Content-Type content=\"text/html; charset=gb2312\">");
fn.writeln("<style type=text/css>.t{color:003366;font-size:9pt;}.pic{font-size:17pt;}body{font-family:\"宋体\";font-size:10.5pt;line-height:160%}A{text-decoration:none}A:Hover{text-decoration:underline}A:visited{color:blue}</style></head><\Script Language=\"JavaScript1.1\">");
fn.writeln("var autoScrollOn=1;var scrollOnFunction;var scrollOffFunction;");
fn.writeln("function scrollit(){ if(!parent.sd.oT.as.checked){autoScrollOn=0;return true;}else{autoScrollOn=1;StartUp();return true;}}function scrollWindow(){if(autoScrollOn==1){this.scroll(0,65000);setTimeout('scrollWindow()',200);}}function scrollOn(){autoScrollOn=1;scrollWindow();}function scrollOff(){autoScrollOn=0;}function StartUp(){parent.onblur=scrollOnFunction;parent.onfocus=scrollOffFunction;scrollWindow();}");
fn.writeln("scrollOnFunction=new Function('scrollOn()');");
fn.writeln("scrollOffFunction=new Function('scrollOff()');");
fn.writeln("StartUp();</\script>");return;
}
function write(){
wh(parent.pub.document);
parent.pub.document.writeln("<body text=#000000 bgcolor=#eeeeff >");
parent.pub.document.writeln("<div id=\"div0\"></div>◆<span style='color:#ff0088'>蓝蝶聊天室</span>◆中心大厅<br>轻轻敲醒沉睡的心灵,慢慢张开你的眼睛,让那昨日的忧伤随聊而去!<hr size=1><div id=Ly></Ly>");
wh(parent.my.document);
var myd=parent.my.document;
myd.writeln("<body text=#000000 bgcolor=#eeeeff >");
myd.writeln("<div id=\"div0\"></div>◆<span style='color:#ff0088'>蓝蝶聊天室</span>◆温馨包厢<br>");
myd.writeln("<span style='color:#0000ff;font-size:9pt'>[这是您的个人包厢,只显示和您相关的发言!]</span><hr size=1><div id=Ly></div>");
}
</script>
<script language="vbscript">
Function URLEncoding(vstrIn)
strReturn = ""
For i = 1 To Len(vstrIn)
ThisChr = Mid(vStrIn,i,1)
If Abs(Asc(ThisChr)) < &HFF Then
strReturn = strReturn & ThisChr
Else
innerCode = Asc(ThisChr)
If innerCode < 0 Then
innerCode = innerCode + &H10000
End If
Hight8 = (innerCode And &HFF00)\ &HFF
Low8 = innerCode And &HFF
strReturn = strReturn & "%" & Hex(Hight8) & "%" & Hex(Low8)
End If
Next
URLEncoding = strReturn
End Function
Function bytes2BSTR(vIn)
strReturn = ""
For i = 1 To LenB(vIn)
ThisCharCode = AscB(MidB(vIn,i,1))
If ThisCharCode < &H80 Then
strReturn = strReturn & Chr(ThisCharCode)
Else
NextCharCode = AscB(MidB(vIn,i+1,1))
strReturn = strReturn & Chr(CLng(ThisCharCode) * &H100 + CInt(NextCharCode))
i = i + 1
End If
Next
bytes2BSTR = strReturn
End Function
</script>
<script language="javascript">
var Me="<%=session("u_name")%>";
<%if session("u_sx")="1" then %>
var Msx="girl.gif";
<%else%>
var Msx="boy.gif";
<%end if%>
var Ts=new oS();
function oS()
{this.F="";
this.T="";
this.E="";
this.W="0";
this.sC="";
this.cL="";
this.Send=sendMsg;
}
function checksays()
{if (document.say.says.value=="") {alert("你要说什么呢?");return false;}
var fm=document.say;
var sC=fm.says.value;
var F=Me
var T=fm.T.options[0].value;
var E=document.oT.userface.selectedIndex;
var W="0"
var cL=fm.says.style.color;
fm.says.value="";
fm.says.focus();
Ts.F=F;
Ts.T=T;
Ts.E=E;
Ts.sC=sC;
Ts.cL=cL;
Ts.W=W;
setTimeout("Ts.Send();",20);
delete(F);delete(sC);delete(fm);delete(cL);delete(T);delete(E);
return false;
}
function sendMsg()
{ if (this.T=="" && this.F=="") {alert("你要对谁说?");return;}
cRld=1;
var sS="F="+code(this.F)+"&T="+code(this.T)+"&sC="+code(this.sC)+"&cL="+this.cL+"&E="+this.E;
sS=URLEncoding(sS)
var oSend=new ActiveXObject("Microsoft.XMLHTTP");
oSend.open("POST","say.asp",false);
oSend.setRequestHeader("Content-Length",sS.length);
oSend.setRequestHeader("CONTENT-TYPE","application/x-www-form-urlencoded");//没有这句就玩不转拉
oSend.send(sS);
var oDom=new ActiveXObject("Microsoft.XMLDOM");
oDom.async=false;
body=bytes2BSTR(oSend.responseBody);
// alert(body);
oDom.loadXML(body);
if(oDom.parseError.errorCode != 0)
{ alert(body);
alert("Sorry.出现了错误");
return }
else
{var aryF=oDom.documentElement.selectNodes("F");
var aryT=oDom.documentElement.selectNodes("T");
var arysC=oDom.documentElement.selectNodes("sC");
var arycL=oDom.documentElement.selectNodes("cL");
var arysJ=oDom.documentElement.selectNodes("sJ");
var aryE=oDom.documentElement.selectNodes("E");
var tmpHtml="";
var img="";
lengt=aryF.length;
for(var i=0;i<lengt;i++){
img="<img src=boy.gif width=12 height=12 border=0>";
tmpHtml="<font style=\'cursor:hand;color:"+arycL(i).text+"\'>"+document.oT.userface.options[aryE(i).text].value+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;
}// end for
}
delete(aryF);delete(aryT);delete(arysC);delete(arycL);delete(arysJ);delete(aryE);
delete(oDom)
delete(oSend)
delete(tmpHtml)
}
function code(Str)
{var A = new RegExp("'","gi")
var B = new RegExp("\"","gi")
Str = Str.replace(/&/gi,"&")
Str = Str.replace(/</gi,"<")
Str = Str.replace(/>/gi,">")
Str = Str.replace(B,""")
Str = Str.replace(/&/gi,"{^amp]")
delete(A)
delete(B)
return(Str)
}
function rp2(Str,Fs,Is)
{while (Str.indexOf(Fs)!=-1)
Str = Str.replace(Fs,Is)
delete(A);
return(Str)
}
'---此页 未完代续-------------