聊天室的内容自动刷新???急急 急

pdgzzgx 2003-11-22 05:29:44
聊天室的内容自动刷新???急急 急
有原代码最好
...全文
234 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
programmer11 2003-11-22
  • 打赏
  • 举报
回复
将输入和显示聊天内容分别放到两个不同的框架里就行了。
pdgzzgx 2003-11-22
  • 打赏
  • 举报
回复
在 <Head >之间加入
<meta HTTP-EQUIV= "refresh " CONTENT= "10(自动刷新时间);URL=chat.htm(要刷新的页面) " charset=gb2312 >
出现一个问题就是。在输入字的时候也要别刷新,有没有办法解决??
riffleliu 2003-11-22
  • 打赏
  • 举报
回复
!<br><br>" & application(UserID)
end if

case "/u"
newsql="select WhoCreate from RoomInfo where WhoCreate='" & UserID & "' and RoomName='" & session("myroom") & "'"
set newrecordset=newconn.Execute (newsql)
if newrecordset.bof then
application(UserID)="不好意思,你無權解開這個房間或者不在那個房間!<br><br>" & application(UserID)
else
newsql="update RoomInfo set IfLocked=false where RoomName='" & session("myroom") & "'"
newconn.Execute (newsql)
application(UserID)="你已經解開了這個房間!<br><br>" & application(UserID)
end if

case "/c"
application(session("myname"))=""


case "/b" '退出聊天室
%>

<script language="javascript">
<!--
top.location.href ="byebye.asp"
//-->
</script>


<%
session.Abandon
Response.End
case "/h" '出現幫助系統

info="/h---出現幫助提示<br>"
info=info & "/j:roomname---加入新的房間<br>"
info=info & "/r---查看當前房間信息<br>"
info=info & "/w:roomname---查看當前擁護情況<br>"
info=info & "/l--鎖住當前房間,只有創建者才能鎖住<br>"
info=info & "/b--退出聊天室<br>"
info=info & "/u--解開某個房間<br>"
info=info & "/t:newtopic--修改話題,只有創建者才能修改<br>"
info=info & "/c--清除聊天內容<br>"

application(UserID)= "<br>" & info & "<br>" & application(UserID)

case "/t"
if right(left(command,3),1)<>":" then
application(UserID)="<br>命令輸入錯誤!<br><br>" & application(UserID)
else
newsql="select WhoCreate from RoomInfo where WhoCreate='" & UserID & "' and RoomName='" & session("myroom") & "'"
set newrecordset=newconn.Execute (newsql)
if newrecordset.bof then
application(UserID)="不好意思,你無權修改這個房間的話題!<br><br>" & application(UserID)
else
newsql="update RoomInfo set Topic='" & mid(command,4) & "' where RoomName='" & session("myroom") & "'"
newconn.Execute (newsql)
newsql="select UserID from UserOnLine where RoomName='" & session("myroom") & "'"
set t_newrecordset=newconn.Execute (newsql)
do while not t_newrecordset.eof
application(t_newrecordset(0))="房間話題被修改為<font color=vbpurplea>" & mid(command,4) & "</font>!<br><br>" & application(t_newrecordset(0))
t_newrecordset.movenext
loop
t_newrecordset.close
set t_newrecordset=nothing

'application(UserID)="你已經修改這個房間的話題為<font color=vbpurplea>" & mid(command,4) & "</font>!<br><br>" & application(UserID)
end if
end if

case else

application(UserID)= "<br>沒有這個命令,請用/h查看幫助<br>" & application(UserID)
end select

else

if request.form("D1")<>"all" then
id_name=Request.Form ("D1")
'Response.Write id_name
temppos=instr(1,id_name,",",1)

yourid=mid(id_name,1,temppos-1)
yournickname=mid(id_name,temppos+1)
end if

set myrecord=server.CreateObject ("ADODB.Recordset")
mysql="select * from UserOnLine where RoomName='" & myroom & "'"
myrecord.Open mysql,"DSN=ChatRoom",1,3

'application.lock

if request.form("D1")="all" or request.form("C1")<> "ON" then

if request.form("D1")="all" then
tempstr="<font color='" & request.form("D2") & "'>" & mynickname & Request.Form ("facing") & "說: " & request.form("T1") & "</font><font color=blue size=0.5>(" & time() & ")</font><br>"
else
tempstr="<font color='" & request.form("D2") & "'>" & mynickname & "只對" & yournickname & Request.Form ("facing") & "說: " & request.form("T1") & "</font><font color=blue size=0.5>(" & time() & ")</font><br>"
end if


do while not myrecord.EOF
application(myrecord("UserId"))=tempstr & application(myrecord("UserId"))
myrecord.MoveNext
loop
application(myroom)=tempstr & Application(myroom)


if len(application(myroom))>1000 then
length2=len(application(myroom))
temppos=instrrev(application(myroom),"<br>",length2)-1
application(myroom)=mid(application(myroom),1,temppos)
end if


else
tempstr="<marquee border='0' behavior='alternate'><font color='" & request.form("D2") & "'>" & mynickname & "對" & yournickname & Request.Form ("facing") & "說:" & request.form("T1") &"</font></marquee>" &"<font colovrr=blue size=0.5>(" & time() & ")</font><br>"
application(yourid)=tempstr & application(yourid)
application(myname)=tempstr & Application(myname)
end if

if len(application(myname))>20000 then
length1=len(application(myname))
temppos=instrrev(application(myname),"<br>",length1-4)-1
application(myname)=mid(application(myname),1,temppos)
end if

application.unlock

end if
'Response.Write (application(UserID))
Response.Write application(UserID)

else

Response.Write application(UserID)

end if

newconn.Close
set newconn=nothing

if changed=true then
%>

<script language="javascript">
<!--
parent.frames[1].location.href="send.asp"

//-->
</script>
<%
end if
%>

<html>
<head>
<meta http-equiv="refresh" content="10;url=content.asp?user=<% =UserID %>">

<title>聊天內容</title>
<meta name="GENERATOR" content="Microsoft FrontPage 3.0">
<base target="ltop">
</head>

<body bgcolor="rgb(254,252,237)">


</body>
</html>
riffleliu 2003-11-22
  • 打赏
  • 举报
回复
<%
dim info
dim changed

set newconn=server.CreateObject ("ADODB.Connection")
newconn.ConnectionString ="DSN=ChatRoom"
newconn.Open


if Request.ServerVariables ("REQUEST_METHOD")="GET" then
UserID=Request.QueryString ("user")
myname=session("myname")'Request.QueryString ("roomname")
end if

if Request.ServerVariables ("REQUEST_METHOD")="POST" then


myname=Request.Form ("userid")
UserID=myname
myroom=session("myroom")'Request.Form ("roomname")
mynickname=Request.Form ("mynickname")

newsql="update UserOnLine set TimeLastTalking='" & now & "' where UserID='" & UserID & "'"
newconn.Execute (newsql)

Application.Lock

if left(Request.Form ("T1"),1)="/" then
command=Request.Form ("T1")
select case left(Request.Form ("T1"),2)

case "/j" '加入新房間
newroom=trim(mid(Request.Form ("T1"),4))
newsql="select RoomName,IfLocked,WhoCreate from RoomInfo where RoomName='" & newroom & "'"
set newrecord=newconn.Execute (newsql)
'Response.Write newrecord("RoomName")
if newrecord.bof or newrecord.eof then
application(UserID)="沒有這個房間號!<br><br>" & application(UserID)
elseif newrecord("IfLocked")=true then
newsql="select UserID from UserOnLine where RoomName='" & newroom & "' and UserID='" & newrecord(2) & "'"
set myrecord=newconn.Execute (newsql)
if not myrecord.BOF then
application(UserID)="這個房間已經上鎖,不能進入!<br><br>" & application(UserID)
else
Create_Leaved=true
newsql="update RoomInfo set IfLocked=false where RoomName='" & newroom & "'"
end if
elseif Create_Leaved=false then
'changed=true
application(UserID)=application(newroom)
newsql1="select UserID from UserOnLine where RoomName='" & newroom & "'"
set newrecord1=server.CreateObject ("ADODB.Recordset")
newrecord1.Open newsql1,"DSN=ChatRoom",1,3

do while not newrecord1.eof
tempname=cstr(newrecord1("UserID"))
'Response.Write newrecord1("UserID")
if tempname<>UserID then
application(tempname)="<br>" & mynickname & "大搖大擺地進來了!(請刷新)<font color=blue size=1>(" & time() & ")</font><br><br>" & application(tempname)
end if
newrecord1.movenext
loop

newsql3="update RoomInfo set HowManyUsers=HowManyUsers+1 where RoomName='" & newroom & "'"
newconn.Execute (newsql3)
newsql4="update RoomInfo set HowManyUsers=HowManyUsers-1 where RoomName='" & myroom & "'"
newconn.Execute (newsql4)

newsql2="update UserOnLine set RoomName='" & newroom & "' where UserID='" & UserID & "'"
newconn.Execute (newsql2)

application(UserID)="你已經進入了房間" & newroom & "<br><br>" & application(UserID)
session("myroom")=newroom

changed=true
newrecord1.Close
set newrecord1=nothing


end if




case "/r" '查看房間信息

newsql="select * from RoomInfo"
set newrecordset1=newconn.Execute (newsql)

do while not newrecordset1.eof
info=info & newrecordset1("RoomName") & "--" & newrecordset1("HowManyUsers") & "--" & newrecordset1("Topic") & "--" & newrecordset1("IfLocked") & "--" & newrecordset1("WhoCreate") & "<br>"
newrecordset1.movenext
loop

'Response.Write info
application(UserID)=info & "<br>" & application(UserID)



case "/w" '查看聊天室成員信息

if len(trim(Request.Form ("T1")))=2 then
newsql="select * from UserOnLine"
set newrecordset2=newconn.Execute (newsql)
do while not newrecordset2.eof
info=info & newrecordset2("UserId") & "--" & newrecordset2("RoomName") & "--" & newrecordset2("IpAdd") & "--" & newrecordset2("TimeLogin") & "<br>"
newrecordset2.movenext
loop

application(UserID)=info & "<br>" & application(UserID)
else
if right(left(Request.Form ("T1"),3),1)<>":" then
info="命令行輸入錯誤<br><br>"
application(UserID)=info & application(UserID)
else
temproom=mid(trim(Request.Form ("T1")),4)
newsql="select RoomName from RoomInfo where RoomName='" & temproom & "'"
set newrecord3=newconn.Execute (newsql)
if not newrecord3.bof then
newsql="select * from UserOnLine where RoomName='" & temproom & "'"
set newrecordset2=newconn.Execute (newsql)

if newrecordset2.bof then
application(UserID)="<br>該房間暫時沒有人!<br><br>" & application(UserID)
else
do while not newrecordset2.eof
info=info & newrecordset2("UserId") & "--" & newrecordset2("RoomName") & "--" & newrecordset2("IpAdd") & "--" & newrecordset2("TimeLogin") & "<br>"
newrecordset2.movenext
loop
application(UserID)="<br>" & info & "<br>" & application(UserID)
end if
else
info="<br>沒有<font color=vbred><strong>" & temproom & "</strong></font>這個房間!<br><br>"
application(UserID)=info & application(UserID)

end if
end if
end if

case "/l" '鎖住本房間
'lockroom=mid(Request.Form ("T1"),4)
newsql="select WhoCreate from RoomInfo where WhoCreate='" & UserID & "' and RoomName='" & session("myroom") & "'"
set newrecordset=newconn.Execute (newsql)
if newrecordset.bof then
application(UserID)="不好意思,你無權鎖住這個房間!<br><br>" & application(UserID)
else
newsql="update RoomInfo set IfLocked=true where RoomName='" & session("myroom") & "'"
newconn.Execute (newsql)

application(UserID)="你已經鎖住了這個房間
junsunchen 2003-11-22
  • 打赏
  • 举报
回复
在<Head>之间加入
<meta HTTP-EQUIV="refresh" CONTENT="10(自动刷新时间);URL=chat.htm(要刷新的页面)" charset=gb2312 >
riffleliu 2003-11-22
  • 打赏
  • 举报
回复
在顯示的那一個加上
<meta http-equiv="refresh" content="10;url="用於顯示字幕的asp文件">
13617650029 2003-11-22
  • 打赏
  • 举报
回复
觉得每个江湖的聊天室这方面都一样的
可以参考一下
monkeys 2003-11-22
  • 打赏
  • 举报
回复
简单的:
顶programmer11(程序员) ( )在<Head>之间加入
<meta HTTP-EQUIV="refresh" CONTENT="10(自动刷新时间);URL=chat.htm(要刷新的页面)" charset=gb2312 >


想做比较好点的,还是参考一下新浪的吧


programmer11 2003-11-22
  • 打赏
  • 举报
回复
在<Head>之间加入
<meta HTTP-EQUIV="refresh" CONTENT="10(自动刷新时间);URL=chat.htm(要刷新的页面)" charset=gb2312 >
pdgzzgx 2003-11-22
  • 打赏
  • 举报
回复
怎么可以看吗?
孟子E章 2003-11-22
  • 打赏
  • 举报
回复
看看新浪的源代码吧
会织网的蚂蚁 2003-11-22
  • 打赏
  • 举报
回复
晚上再给你说,哈哈。

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧