DIV CSS 佈局教程網

 DIV+CSS佈局教程網 >> 網頁腳本 >> JavaScript入門知識 >> AJAX入門 >> AJAX詳解 >> XMLHTTP+Javascript+Asp寫得聊天室,無刷新實現(4)
XMLHTTP+Javascript+Asp寫得聊天室,無刷新實現(4)
編輯:AJAX詳解     
 這是最重要的一個了。也很大。我的習慣不太好。沒有加詳細的注釋,認真看吧。
#########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="/School/UploadFiles_7810/201104/20110423155819991.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=/School/UploadFiles_7810/201104/20110423155819991.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)
}

'---此頁 未完代續-------------
XML學習教程| jQuery入門知識| AJAX入門| Dreamweaver教程| Fireworks入門知識| SEO技巧| SEO優化集錦|
Copyright © DIV+CSS佈局教程網 All Rights Reserved