纯ASP实现的“无刷新”聊天室

本文介绍了一种使用ASP技术实现的实时聊天室方案。通过隐藏框架和定时刷新的方式达到页面无闪烁的效果,并展示了具体的代码实现,包括用户登录、发送消息、修改用户名等功能。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

以前看到网易上的聊天室,很有意思,就想学学它的实现原理,但就是找不到相关的资料,偶然的一次,在网上看到有人说用隐藏框架来刷新读取数据这样能实现页面不闪烁,但状态栏上的进度条还是有的,这样我就在别的页面建立连接用“open”命令去掉状态栏等来打开聊天室主窗口就可以实现“无刷新”了。下面是下载地址:
纯ASP实现的“无刷新”聊天室下载地址

记住,要用open命令打开就没有状态栏上的进度条(以屏幕分辨率1024*768为例):

window.open("chat_index.asp","chat",width=1000,height=700,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0)

同时也贴上代码吧!


  1<%
  2select case request("action")
  3case "talk"
  4    call talk()
  5case "showh"
  6    call showh()
  7case "listh"
  8    call listh()
  9case "send"
 10    call send()
 11case "modify"
 12    call modify()
 13case "music"
 14    call music()
 15case "exitchat"
 16    call exitchat()
 17case else 
 18    call main()
 19end select
 20
 21sub exitchat()
 22if isarray(session("dv_user")) then 
 23    dv_user=session("dv_user")
 24
 25    Application.lock
 26    Application("onlinelist")=replace(Application("onlinelist"),session("dv_user")(0)&" ","")
 27    Application.Unlock
 28    
 29    msgstr="parent.showmsg('1','"&session("dv_user")(0)&"','大家','【系统消息】"&session("dv_user")(0)&"离开了聊天室。。!','AA00CC','0','"&time()&"'); "
 30    
 31    Application.Lock
 32    sd=Application("chat_sd")
 33    line=int(Application("chat_line"))
 34    Application("chat_line")=line+1
 35    Dim newsd(50)
 36    j=1
 37    for i=3 to 50 step 2
 38    newsd(j)=sd(i)
 39    newsd(j+1)=sd(i+1)
 40    j=j+2
 41    next
 42    newsd(49)=line+1
 43    newsd(50)=msgStr
 44    Application("chat_sd")=newsd
 45    Application.UnLock
 46    
 47    dv_user(1)=    Application("chat_line")
 48    session("dv_user")=""
 49end if
 50%>
 51<script LANGUAGE="JavaScript">
 52if(window!=window.top){top.location.href=location.href;}
 53window.close();
 54</script>
 55<%
 56end sub
 57
 58sub listh()
 59    online=Application("onlinelist")
 60    online=split(online," ")
 61    Response.Write "<script language=javascript>parent.list.document.open();"
 62    Response.Write "parent.list.document.writeln('<body bgcolor=#cc99ff bgproperties=fixed >');"
 63    Response.Write "parent.list.document.writeln('<style type=text/css>A:visited{TEXT-DECORATION: none;Color:#000000}A:active{TEXT-DECORATION: none;Color:#000000}A:hover{TEXT-DECORATION: underline;Color:#000000}A:link{text-decoration: none;Color:#000000}BODY{FONT-FAMILY: 宋体; FONT-SIZE: 12px;}</style>');"
 64    Response.Write "msg='<a href=javascript:parent.setuser(\'大家\'); target=talk>大家</a><br>';parent.list.document.writeln('当前在线("&ubound(online)&")人<br>--------------------');"
 65    for i=lbound(online) to ubound(online)-1
 66        Response.Write "msg=msg+'<a href=javascript:parent.setuser(\'"&online(i)&"\'); target=talk>"&online(i)&"</a><br>';"
 67    next
 68    Response.Write "parent.list.document.writeln(msg);"
 69    Response.Write "</script>"
 70    Response.Write "<script Language=JavaScript>setTimeout('this.location.reload();',7000);</script>"
 71end sub
 72
 73sub send()
 74    Response.Buffer =true
 75    if not isarray(session("dv_user")) then 
 76        Response.Write "未登陆不能发言!"
 77        Response.End 
 78    end if
 79    dv_user=session("dv_user")
 80    username=dv_user(0)
 81    userline=dv_user(1)
 82    sendtime=dv_user(2)
 83    send_time=now()
 84    
 85    msgstr=Request.Form ("post_content")
 86    towho=Request.Form ("towho")
 87    msgcolor=Request.Form ("msgcolor")
 88    secret=Request.Form ("secret")
 89    if msgcolor="" then Response.End
 90    
 91    if secret<>1 then secret=0
 92    
 93    if Instr(msgstr,"[tu]")<>0 then
 94        dim reg
 95        set reg=new regexp
 96        reg.IgnoreCase=true
 97        reg.Global=true
 98        reg.Pattern="(\[tu\])([1234567890])(\[\/tu\])"
 99        msgstr=reg.Replace(msgstr,"<img src=emot/em$2.gif>")
100        reg.Pattern="(\[tu\]1)([1234567890])(\[\/tu\])"
101        msgstr=reg.Replace(msgstr,"<img src=emot/em1$2.gif>")
102        reg.Pattern="(\[tu\]2)([1234567890])(\[\/tu\])"
103        msgstr=reg.Replace(msgstr,"<img src=emot/em2$2.gif>")
104        set reg=nothing
105    end if
106
107    msgstr="parent.showmsg('0','"&username&"','"&towho&"','"&msgstr&"','"&msgcolor&"','"&secret&"','"&time()&"');"
108    
109    Application.Lock
110    sd=Application("chat_sd")
111    line=int(Application("chat_line"))
112    Application("chat_line")=line+1
113    Dim newsd(50)
114    j=1
115    for i=3 to 50 step 2
116        newsd(j)=sd(i)
117        newsd(j+1)=sd(i+1)
118        j=j+2
119    next
120    newsd(49)=line+1
121    newsd(50)=msgstr
122    Application("chat_sd")=newsd
123    Application.UnLock
124    
125    dv_user=session("dv_user")
126    username=dv_user(0)
127    userline=dv_user(1)
128    sendtime=dv_user(2)
129    send_time=now()
130    sd=Application("chat_sd")
131    newuserline=0
132    for i=1 to 50 step 2
133        newuserline=sd(i)
134        if sd(i)>userline  then
135            Response.Write "<script Language=JavaScript>"&sd(i+1)&"</script>"
136        end if
137    next
138    dv_user(1= newuserline
139    dv_user(2= send_time
140    session("dv_user")=dv_user
141    Response.End
142end sub
143
144sub showh()
145    if not isarray(session("dv_user")) then Response.End
146    dv_user=session("dv_user")
147    userline=dv_user(1)
148    sd=Application("chat_sd")
149    newuserline=0
150    for i=1 to 50 step 2
151        newuserline=sd(i)
152        if sd(i)>userline  then
153            Response.Write "<script Language=JavaScript>"&sd(i+1)&"</script>"
154        end if
155    next
156    if newuserline>userline then dv_user(1)=newuserline
157    session("dv_user")=dv_user
158    Response.Write "<script Language=JavaScript>setTimeout('this.location.reload();',3000);</script>"
159    Response.End
160end sub
161
162sub modify()
163%>
164<html>
165<head>
166<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
167<title>聊天室</title>
168<style type="text/css">
169A:visited{TEXT-DECORATION: none;Color:#000000}
170A:active{TEXT-DECORATION: none;Color:#000000}
171A:hover{TEXT-DECORATION: underline;Color:#000000}
172A:link{text-decoration: none;Color:#000000}
173BODY{FONT-FAMILY: "宋体"; FONT-SIZE: 12px;
174background-color:#CCCCFF;
175margin-top:3px;
176margin-bottom:2px;
177}
178TD,p,div,br{FONT-FAMILY: "宋体"; FONT-SIZE: 12px;Color:#000000;}
179FORM{FONT-FAMILY: "宋体"; FONT-SIZE: 12px}
180OPTION{FONT-FAMILY: "宋体"; FONT-SIZE: 12px}
181INPUT{BORDER-TOP-WIDTH: 1px; PADDING-RIGHT: 1px; PADDING-LEFT: 1px; BORDER-LEFT-WIDTH: 1px; FONT-SIZE: 9pt; BORDER-LEFT-COLOR: #cccccc; BORDER-BOTTOM-WIDTH: 1px; BORDER-BOTTOM-COLOR: #cccccc; PADDING-BOTTOM: 1px; BORDER-TOP-COLOR: #cccccc; PADDING-TOP: 1px; HEIGHT: 18px; BORDER-RIGHT-WIDTH: 1px; BORDER-RIGHT-COLOR: #cccccc; font-family: "宋体"; font-size: 12px}
182select {border-width: 1px; border-color: #000000; background-color: #eeeeee; font-family: "宋体"; font-size: 12px;}
183</style>
184</head>
185<body>
186<%
187if request("opa")="modify" then
188if not isarray(session("dv_user")) then 
189    Response.Redirect "chat_index.asp?action=exitchat"
190else
191    dv_user=session("dv_user")
192    newname=Request.Form ("newname")
193    if Instr(LCase(Application("onlinelist")),LCase(newname&" "))<>0 then 
194        Response.Write "<script>alert('系统中己存在这个用户名!');this.location.href='chat_index.asp?action=modify';</script>"
195        Response.End 
196    end if
197
198    Application.lock
199    Application("onlinelist")=replace(Application("onlinelist"),dv_user(0)&" ",newname&" ")
200    Application.Unlock
201
202    msgstr="parent.showmsg('1','"&dv_user(0)&"','大家','【系统消息】"&dv_user(0)&"己改名为<a href=javascript:parent.setuser(\'"&newname&"\'); target=talk>"&newname&"</a>!','AA00CC','0','"&time()&"'); "
203    Application.Lock
204    sd=Application("chat_sd")
205    line=int(Application("chat_line"))
206    Application("chat_line")=line+1
207    Dim newsd(50)
208    j=1
209    for i=3 to 50 step 2
210        newsd(j)=sd(i)
211        newsd(j+1)=sd(i+1)
212        j=j+2
213    next
214    newsd(49)=line+1
215    newsd(50)=msgStr
216    Application("chat_sd")=newsd
217    Application.UnLock
218    
219    dv_user(0)=newname
220    session("dv_user")=dv_user
221    Response.Write "<script language=javascript>parent.username='"&newname&"';parent.talk.document.talk.username.value='"&newname&"';parent.listh.location.reload();this.location.href='chat_index.asp?action=modify';</script>"
222end if
223else
224%>
225<form method="post" action="chat_index.asp?action=modify&opa=modify" name="modifyname">&nbsp;&nbsp;名: <input name="newname" type="text" size="10">&nbsp;<input name="" type="submit" value="改名"></form>
226<%
227end if
228%>
229</body>
230</html>
231<script language="javascript">
232parent.talk.document.talk.content.focus();
233</script>
234<%
235end sub
236
237sub music()
238%>
239<html>
240<head>
241<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
242<title>聊天室</title>
243<style type="text/css">
244A:visited{TEXT-DECORATION: none;Color:#000000}
245A:active{TEXT-DECORATION: none;Color:#000000}
246A:hover{TEXT-DECORATION: underline;Color:#000000}
247A:link{text-decoration: none;Color:#000000}
248BODY{FONT-FAMILY: "宋体"; FONT-SIZE: 12px;
249background-color:#CCCCFF;
250margin-top:3px;
251margin-bottom:2px;
252}
253TD,p,div,br{FONT-FAMILY: "宋体"; FONT-SIZE: 12px;Color:#000000;}
254FORM{FONT-FAMILY: "宋体"; FONT-SIZE: 12px}
255OPTION{FONT-FAMILY: "宋体"; FONT-SIZE: 12px}
256INPUT{BORDER-TOP-WIDTH: 1px; PADDING-RIGHT: 1px; PADDING-LEFT: 1px; BORDER-LEFT-WIDTH: 1px; FONT-SIZE: 9pt; BORDER-LEFT-COLOR: #cccccc; BORDER-BOTTOM-WIDTH: 1px; BORDER-BOTTOM-COLOR: #cccccc; PADDING-BOTTOM: 1px; BORDER-TOP-COLOR: #cccccc; PADDING-TOP: 1px; HEIGHT: 18px; BORDER-RIGHT-WIDTH: 1px; BORDER-RIGHT-COLOR: #cccccc; font-family: "宋体"; font-size: 12px}
257select {border-width: 1px; border-color: #000000; background-color: #eeeeee; font-family: "宋体"; font-size: 12px;}
258</style>
259<script language="javascript">
260function ws(v){
261 var newv = escape(v);
262 var fv = v.substring(0, v.lastIndexOf("."));
263 if(newv == v || v.indexOf("'") != -1){
264  if(fv.length > 16){fv = fv.substring(0,16+ ""}
265  document.write("<option value=\"" + v + "\">" + fv + "</option>");
266 }
267 else{
268  if(fv.length > 9){fv = fv.substring(0,9+ ""}
269  document.write("<option value=\"" + v + "\">" + fv + "</option>");
270 }
271}
272function check(){
273 if(document.music.musiclist.selectedIndex == -1){
274  alert("请选择所需曲目。");
275  return false;
276 }
277}
278function playsong(){
279 if(document.music.musiclist.selectedIndex == -1){
280  alert("请选择所需曲目。");
281  return false;
282 }
283 sn = document.music.musiclist.options[document.music.musiclist.selectedIndex].value;
284 
285 url = "song/" + escape(sn);
286 
287 parent.musich.document.open();
288 parent.musich.document.writeln("<bgsound src=\"" + url + "\" loop=1>");
289 parent.musich.document.close();
290 parent.showmsg('1','','',"<font color=black>【点歌】</font>正在下载并播放歌曲<font color=A00000>《" + sn.substring(0, sn.lastIndexOf(".")) + "》</font>,请稍候……",'0088FF','0','<%=time()%>');
291}
292function stopsong(){
293 parent.musich.location.href = "about:blank";
294}
295</script>
296</head>
297<body>
298<form name="music" method="post" onsubmit="return(check())">
299  点歌:
300    <select name="musiclist">
301    <option>----------</option>
302    <%
303    Set fs=CreateObject("Scripting.FileSystemObject")
304    songpath=Server.Mappath("song")
305    Set f=fs.GetFolder(songpath)
306    Set fc=f.Files
307    For Each f1 in fc
308        fn=f1.name
309        Response.Write "<script>ws(" & chr(34& fn & chr(34& ");</script>" & chr(13& chr(10)
310    next
311    Set f=nothing
312    Set fc=nothing
313    Set fs=nothing
314    %>
315    </select>
316    <input type="button" name="play" value="播放" onclick="javascript:playsong();parent.talk.document.talk.content.focus();">
317    <input type="button" name="stop" value="停止" onclick="javascript:stopsong();parent.talk.document.talk.content.focus();">
318</form>
319</body>
320</html>
321<%
322end sub
323
324sub talk()
325%>
326<html>
327<head>
328<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
329<title>聊天室</title>
330<style type="text/css">
331A:visited{TEXT-DECORATION: none;Color:#000000}
332A:active{TEXT-DECORATION: none;Color:#000000}
333A:hover{TEXT-DECORATION: underline;Color:#000000}
334A:link{text-decoration: none;Color:#000000}
335.t{LINE-HEIGHT: 1.4}
336BODY{FONT-FAMILY: "宋体"; FONT-SIZE: 12px;
337background-color:#CCCCFF;
338margin-top:3px;
339margin-bottom:2px;
340}
341TD,p,div,br{FONT-FAMILY: "宋体"; FONT-SIZE: 12px;Color:#000000;}
342FORM{FONT-FAMILY: "宋体"; FONT-SIZE: 12px}
343OPTION{FONT-FAMILY: "宋体"; FONT-SIZE: 12px}
344INPUT{BORDER-TOP-WIDTH: 1px; PADDING-RIGHT: 1px; PADDING-LEFT: 1px; BORDER-LEFT-WIDTH: 1px; FONT-SIZE: 9pt; BORDER-LEFT-COLOR: #cccccc; BORDER-BOTTOM-WIDTH: 1px; BORDER-BOTTOM-COLOR: #cccccc; PADDING-BOTTOM: 1px; BORDER-TOP-COLOR: #cccccc; PADDING-TOP: 1px; HEIGHT: 18px; BORDER-RIGHT-WIDTH: 1px; BORDER-RIGHT-COLOR: #cccccc; font-family: "宋体"; font-size: 12px}
345select {border-width: 1px; border-color: #000000; background-color: #eeeeee; font-family: "宋体"; font-size: 12px;}
346</style>
347<script language=javascript>
348username=parent.getuser();
349function selway(){if(document.talk.secret.value=='0'){document.talk.secret.value='1'}else{document.talk.secret.value='0'}}
350function bs(){
351document.talk.content.style.color=document.talk.msgcolor.value;
352document.talk.content.focus();}
353function send()
354{
355var post_content=document.talk.post_content.value
356var content=document.talk.content.value
357  while(post_content.indexOf(">") != -1 || post_content.indexOf("<") != -1 || post_content.indexOf(" ") != -1 || post_content.indexOf(" ") != -1 || post_content.indexOf(",") != -1 || content.indexOf(" ") != -1 || content.indexOf(" ") != -1 || content.indexOf(",") != -1 || content.indexOf("<") != -1 || content.indexOf(">") != -1){
358   post_content = post_content.replace(" ","");
359   post_content = post_content.replace(" ","");
360   post_content = post_content.replace(",","");
361   post_content = post_content.replace("<","&lt;")
362   post_content = post_content.replace(">","&gt;")
363   content = content.replace(" ","");
364   content = content.replace(" ","");
365   content = content.replace(",","");
366   content = content.replace("<","&lt;")
367   content = content.replace(">","&gt;")
368  }
369if (content==''){alert('请输入发言!');document.talk.content.focus();return false}
370if (content==post_content){alert('请不要重复发言!!');document.talk.content.focus();return false}
371this.document.talk.Submit.disabled=1;
372this.document.talk.post_content.value=content;
373this.document.talk.content.value='';
374this.document.talk.tu.value='0';
375setTimeout("document.talk.Submit.disabled=0;",3000);
376document.talk.content.focus();
377}
378function exit(){
379 if(confirm('您确定要退出聊天室吗?')){
380  setTimeout("top.location.href='chat_index.asp?action=exitchat';"500);
381 }
382}
383function chgfoc()
384{
385    document.talk.content.focus();
386    var e = event.srcElement;
387    var r =e.createTextRange();
388    r.moveStart("character",e.value.length);
389    r.collapse(true);
390    r.select();
391}
392</script>
393</head>
394<body onLoad="document.talk.content.focus();">
395<form name="talk" method="post" target="send" action='chat_index.asp?action=send' onsubmit='return(send());'>
396发言人: 
397<input type=text name='username' value='' readonly  style="text-align:center;font-size:12px;color:CC3366" size=10 maxlength=10> 
398&nbsp;&nbsp;颜色:
399<select name='msgcolor' onchange="document.talk.content.focus();bs(document.talk.msgcolor.value)" style='font-size:12px'>
400<option style="background-color:000000;color:000000" value="000000">黑色</option>
401<option style="background-color:0088FF;color:0088FF" value="0088FF">海蓝</option>
402<option style="background-color:0000FF;color:0000FF" value="0000FF">亮蓝</option>
403<option style="background-color:000088;color:000088" value="000088">深蓝</option>
404<option style="background-color:888800;color:888800" value="888800">黄绿</option>
405<option style="background-color:008888;color:008888" value="008888">蓝绿</option>
406<option style="background-color:008800;color:008800" value="008800">橄榄</option>
407<option style="background-color:8888FF;color:8888FF" value="8888FF">淡紫</option>
408<option style="background-color:AA00CC;color:AA00CC" value="AA00CC">紫色</option>
409<option style="background-color:8800FF;color:8800FF" value="8800FF" selected>蓝紫</option>
410<option style="background-color:888888;color:888888" value="888888">灰色</option>
411<option style="background-color:CCAA00;color:CCAA00" value="CCAA00">土黄</option>
412<option style="background-color:FF8800;color:FF8800" value="FF8800">金黄</option>
413<option style="background-color:CC3366;color:CC3366" value="CC3366">暗红</option>
414<option style="background-color:FF00FF;color:FF00FF" value="FF00FF">紫红</option>
415<option style="background-color:3366CC;color:3366CC" value="3366CC">蓝黑</option>
416</select>
417
418图片:
419<select name='tu' onchange="document.talk.content.value=(this.value);chgfoc();" style='font-size:12px'>
420<option value="0" selected>----</option>
421<option value="[tu]1[/tu]">我的天</option>
422<option value="[tu]2[/tu]">开心</option>
423<option value="[tu]3[/tu]">555~~</option>
424<option value="[tu]4[/tu]">哇有趣</option>
425<option value="[tu]5[/tu]">必胜</option>
426<option value="[tu]6[/tu]">支持</option>
427<option value="[tu]7[/tu]">怕怕</option>
428<option value="[tu]8[/tu]">讨厌</option>
429<option value="[tu]9[/tu]">收到</option>
430<option value="[tu]10[/tu]">不解</option>
431<option value="[tu]11[/tu]"></option>
432<option value="[tu]12[/tu]">傻了</option>
433<option value="[tu]13[/tu]">大汗</option>
434<option value="[tu]14[/tu]">汗!!!</option>
435<option value="[tu]15[/tu]">欠揍</option>
436<option value="[tu]16[/tu]">踩~</option>
437<option value="[tu]17[/tu]">什么</option>
438<option value="[tu]18[/tu]">砍~</option>
439<option value="[tu]19[/tu]">正点</option>
440<option value="[tu]20[/tu]">晕死</option>
441<option value="[tu]21[/tu]">开心点</option>
442<option value="[tu]22[/tu]">路过</option>
443<option value="[tu]23[/tu]">你个猪头</option>
444<option value="[tu]24[/tu]">送你的花</option>
445<option value="[tu]25[/tu]">挖哈哈哈</option>
446<option value="[tu]26[/tu]">拜拜了你</option>
447</select>
448<input type=checkbox name='secret' value='0' onclick=selway();>
449<a href=# onClick='document.talk.secret.checked=!(document.talk.secret.checked);selway();document.talk.content.focus();' title="“激活/禁止”私聊开关">私聊</a>
450<input type='checkbox' name='as' accesskey='a' checked onClick='parent.scrollit()'>
451<a href=# onClick='document.talk.as.checked=!(document.talk.as.checked);parent.scrollit();document.talk.content.focus();' title="“激活/禁止”对话区自动滚屏">滚屏</a>
452
453<br>
454对话人: 
455<input type=text name='towho' value='大家' readonly  onclick=javascript:document.talk.towho.value='大家';document.talk.content.focus(); style="text-align:center;font-size:12px;color:CC3366" size=10 maxlength=10>
456<input type=hidden name=post_content value=''>
457 &nbsp;对话: 
458<input type="text" name="content" size="40" style='font-size:12px'>
459<input type="submit" name="Submit" value="提交">
460<span style=" padding-left:100px; vertical-align:middle;">
461<a href=# onclick=exit();>退 出</a>------离开时请点这里,谢谢!
462</span>
463</form>
464</body>
465</html>
466<script>
467bs()
468document.talk.username.value=username;
469parent.write();
470</script>
471<%
472end sub
473
474sub main()
475    randomize()
476    mum=int(rnd*9999)
477    username="游客"&mum
478    if Application("chat_line")="" then 
479         Dim sd_init(50)
480         for i=1 to 48
481             sd_init(i)=0
482         next
483         sd_init(49)=1
484         sd_init(50)="数组初始化成功!"
485         Application("chat_sd")=sd_init
486         Application("chat_line")=1
487         Application("onlinelist")=""
488    end if
489    if not isarray(session("dv_user")) then 
490        dim dv_user(3)
491        dv_user(0)=username
492        dv_user(1)=Application("chat_line")
493        dv_user(2)=now()
494        dv_user(3)=0
495        session("dv_user")=dv_user
496    else
497        dv_user=session("dv_user")
498    end if
499    
500if Instr(LCase(Application("onlinelist")),LCase(dv_user(0)&" "))=0 then
501    Application.lock
502    Application("onlinelist")=Application("onlinelist")&dv_user(0)&" "
503    Application.UnLock
504    if dv_user(3)=0 then
505        Application.lock
506        sd=Application("chat_sd")
507        line=int(Application("chat_line"))
508        Application("chat_line")=line+1
509        Dim newsd(50)
510        j=1
511        for i=3 to 50 step 2
512            newsd(j)=sd(i)
513            newsd(j+1)=sd(i+1)
514            j=j+2
515        next
516        newsd(49)=line+1
517        newsd(50)="parent.showmsg('1','"&dv_user(0)&"','大家','【系统消息】<a href=javascript:parent.setuser(\'"&dv_user(0)&"\'); target=talk>【"&dv_user(0)&"】</a>进入聊天室!','AA00CC','0','"&time()&"'); "
518        Application("chat_sd")=newsd
519        Application.UnLock
520    end if
521    dv_user(3)=1
522    session("dv_user")=dv_user
523end if
524
525%>
526<html>
527<head>
528<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
529<title>聊天室</title>
530<script language=javascript>
531var username='<%=session("dv_user")(0)%>';
532var autoScroll=1;
533var lheight=140;
534var fsize=10.5;
535var bgcolor='#99ccff';
536var chatimage='1';
537var tbclu='true'
538var ph = "<%=ph%>";
539var masklist=' ';
540
541function write()
542{
543parent.show.document.open();
544parent.show.document.writeln("<html><head><title>聊天室</title><meta http-equiv=Content-Type content=\"text/html; charset=gb2312\">");
545parent.show.document.writeln("<style type=text/css>.p{font-size:20pt}.l{line-height:" + lheight + "%}.t{color:Fshowmsg0FF;font-size:9pt;}body{font-family:\"宋体\";font-size:" + fsize + "pt;line-height:" + lheight + "%}INPUT{BORDER-TOP-WIDTH: 1px; BORDER-LEFT-WIDTH: 1px; FONT-SIZE: 9pt; BORDER-BOTTOM-WIDTH: 1px; BACKGROUND-COLOR: #efefef; BORDER-RIGHT-WIDTH: 1px}A{text-decoration:none}div{background:#fdf5e6;line-height:" + lheight + "%}td{font-family:\"宋体\";font-size:" + fsize + "pt;}A:Hover{text-decoration:underline}A:visited{color:blue}</style></head>");
546parent.show.document.writeln("<body topmargin=3 bgcolor=#eeeeee>");
547parent.show.document.writeln("<\script>function autoscrollnow(){this.scroll(0,80000);}<\/script>");
548parent.show.document.writeln("<span><font color=purple><b>---------------------------------------聊天中心---------------------------------------</b></font></span>");
549parent.show.document.writeln("<table width=500 align=center><tr width=100%><td align=left><font color=purple><pre>                       _  _<br>                      ( \\/ )<br>               .---.   \\  /   .-\"-.<br>              /   6_6   \\/   / 4 4 \\<br>              \\_  (__\\       \\_ v _/<br>              //   \\\\        //   \\\\<br>             ((     ))      ((     ))<br>       =======\"\"===\"\"========\"\"===\"\"=======<br>                |||            |||<br>                 |              |</pre></font></td></tr></table>");
550parent.show.document.writeln("<span><font color=red>【系统消息】</font>欢迎【"+username+"】光临!</span><br>");
551}
552function setuser(str){parent.talk.document.talk.towho.value=str;parent.talk.document.talk.content.focus();}
553function showmsg(type,from,to,content,msgcolor,secret,saytime)
554{
555if(type=='0'){
556if (from==username)
557{var zj="【<a href=javascript:parent.setuser('"+from+"'); target=talk><font color='#CC3366'>我</font></a>】";}
558else
559{var zj="<a href=javascript:parent.setuser('"+from+"'); target=talk><font color='#CC3366'>"+from+"</font></a>";}
560if (to==username)
561{var br="【<a href=javascript:parent.setuser('"+to+"'); target=talk><font color='#CC3366'>我</font></a>】";}
562else
563{var br="<a href=javascript:parent.setuser('"+to+"'); target=talk><font color='#CC3366'>"+to+"</font></a>";}
564
565//私聊
566if (secret=='1')
567    {msg="<font color=red>〖私聊〗</font>"+zj+""+br+"说:<font color="+msgcolor+">"+content+"</font>";}
568else
569    {msg=zj+""+br+"说:<font color="+msgcolor+">"+content+"</font>"}
570
571if (secret=='1' && (from!=username && to!=username)){return false}
572msg=msg+"<font color=red size=1pt>("+saytime+")</font><br>"
573
574parent.show.document.writeln(msg);
575if (autoScroll==1) {parent.show.autoscrollnow();}
576}else{
577msg="<font color="+msgcolor+">"+content+"</font><br>"
578parent.show.document.writeln(msg);
579}
580}
581
582function scrollit(){
583    if(!parent.talk.document.talk.as.checked)
584        {autoScroll=0;}
585    else
586        {autoScroll=1;parent.show.autoscrollnow();}
587}
588function getuser()
589{
590return username;
591}
592window.resizeTo(window.screen.width,window.screen.height-29);
593window.moveTo(0,0);
594window.focus();
595</script>
596</head>
597
598<frameset rows="*,75" cols="*" border="0" framespacing="0">
599  <frameset rows="*" cols="*,171" framespacing="0" border="0">
600    <frameset rows="0,*" cols="*" framespacing="0" border="0">
601        <frame src="chat_index.asp?action=showh" name="showh" frameborder="NO" scrolling="NO" noresize>
602        <frame src="about:blank" name="show">
603    </frameset>
604    <frameset rows="0,*" cols="*" framespacing="0" border="0">
605        <frame src="chat_index.asp?action=listh" name="listh" scrolling="NO" noresize>
606        <frame src="about:blank" name="list" noresize>
607    </frameset>
608  </frameset>
609  <frameset rows="50,25,0" cols="*" border="0" framespacing="0">
610      <frame src="chat_index.asp?action=talk" name="talk" scrolling="NO" noresize>
611      <frameset rows="*" cols="200,*,0" framespacing="0" border="0">
612          <frame src="chat_index.asp?action=modify" name="modify" frameborder="NO" scrolling="NO" noresize>
613        <frame src="chat_index.asp?action=music" name="music" frameborder="NO" scrolling="NO" noresize>
614        <frame src="about:blank" name="musich" frameborder="NO" scrolling="NO" noresize>
615      </frameset>
616      <frame src="chat_index.asp?action=send" name="send" frameborder="NO" scrolling="NO" noresize>
617  </frameset>
618</frameset>
619<noframes><body bgcolor="#FFFFFF" text="#000000">
620
621</body></noframes>
622</html>
623<%
624end sub
625%>

 

转载于:https://www.cnblogs.com/pains/archive/2007/10/06/915554.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值