刷新:

时光888 2004-09-24 02:54:58
<head>
<meta http-equiv=refresh content="5;<%=MySelf %>">
</head>
我想自动刷新就出现谈话内容.可以每次都要工人刷新.上面刷新代码有错吗?
好像屏幕有闪动,可谈话内容不出来.
...全文
110 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
iuhxq 2004-09-24
  • 打赏
  • 举报
回复
103895
时光888 2004-09-24
  • 打赏
  • 举报
回复
iuhxq(小灰)
那么利害能不能留个QQ,以后要请教你.
iuhxq 2004-09-24
  • 打赏
  • 举报
回复
chat_log.asp:
<!--#include file="conn.asp"-->
<!--#include file="chklogin.asp"-->
<%
Response.Expires = -1
Response.ExpiresAbsolute = Now() - 1
Response.cachecontrol = "no-cache"
if isnumeric(request("id")) then
set rs=conn.execute("select top 50 * from chat_log where chat_id>"&request("id")&" order by chat_id desc")
while not rs.eof
response.Write(escape(rs("chat_id")&"*"&rs("roomid")&"*"&rs("sendtime")&rs("msgBody")&"#" ))
rs.movenext
wend
end if
%>

chat_room.asp:
<!--#include file="conn.asp"-->
<!--#include file="chklogin.asp"-->
<%
Response.Expires = -1
Response.ExpiresAbsolute = Now() - 1
Response.cachecontrol = "no-cache"
set rs=conn.execute("select * from chat_room order by id desc")
while not rs.eof
response.Write(escape( rs("id")&"*"&rs("roomname")&"#" ))
rs.movenext
wend
%>

chat_user.asp:
<!--#include file="conn.asp"-->
<!--#include file="chklogin.asp"-->
<%
Response.Expires = -1
Response.ExpiresAbsolute = Now() - 1
Response.cachecontrol = "no-cache"
set rs=conn.execute("select * from chat_user where state=1 order by userid")
while not rs.eof
response.Write(escape( rs("srcphone")&rs("userid")&"*"&rs("nickname")&"*"&rs("roomid")&"#" ))
rs.movenext
wend
%>

chat_send.asp:

<!--#include file="conn.asp"-->
<!--#include file="chklogin.asp"-->
<%
'exec chat '13500000000','ME','278810','571','1'
phone=session("phone")
province=session("province")
content=Request("content")
srcphone=Request("srcphone")
conn.execute("exec chat '"&phone&"','"&content&"','"&srcphone&"','"&province&"','1'")
'savefile "chat '"&phone&"','"&content&"','"&srcphone&"','"&province&"','1'"
'function savefile(str)
' set fso=server.CreateObject("scripting.filesystemobject")
' set f1=fso.opentextfile(server.MapPath("./test.txt"),8,true)
' f1.write(str)
' f1.close
' set fso=nothing
'end function
%>
jzywh 2004-09-24
  • 打赏
  • 举报
回复

<%
MySelf = "本页面的文件名"
%>
<head>
<meta http-equiv=refresh content="5;<%=MySelf %>">
</head>
iuhxq 2004-09-24
  • 打赏
  • 举报
回复
function.js:
// JavaScript Document
window.onload=function init()
{
Load_log();
Load_user();
Load_room();
}
function GetPage(url)
{
var xml = new ActiveXObject("Microsoft.XMLHTTP");
xml.open("GET",url,false);
xml.send();
return unescape(xml.ResponseText);
}
function PostData(url,Body)
{
var xml = new ActiveXObject("Microsoft.XMLHTTP");
xml.open("POST",url,false);
xml.setRequestHeader("Content-Type","application/x-www-form-urlencoded")
xml.setRequestHeader("Content-Length",escape(Body).length)
xml.send(Body);
}
function Load_room()
{
var value = GetPage("chat_room.asp");
var str = value.split("#");
var id,roomname,temp;
room = new ActiveXObject("Scripting.Dictionary");
var i=str.length-1;
while(i-- >0)
{
temp = str[i].split("*");
id = temp[0];
roomname = temp[1];
room.Add(id,roomname);
}
Show_room();
//t_room = setTimeout("Load_room();",60000);
}
function Show_room()
{
var i;
for(i=document.form1.chat_room.options.length;i>0;i--)
{
document.form1.chat_room.options.remove(i-1);
}
document.form1.chat_room.options.add(new Option("所有",0));
a = (new VBArray(room.Items())).toArray();
for (i in a)
{
document.form1.chat_room.options.add(new Option(a[i],i));
}
document.form1.chat_room.selectedIndex = myroomid;
}
function Load_user()
{
var value = GetPage("chat_user.asp");
var str = value.split("#");
var userid,nickname,roomid,temp;
var i;
i = user.length-1;
while(i-- >=0)
{
user.pop();
}
i = str.length-1;
while(i-- >0)
{
temp = str[i].split("*");
userid = temp[0];
nickname = temp[1];
roomid = temp[2];
user.push(userid,nickname,roomid);
}
Show_user();
//t_user = setTimeout("Load_user();",60000);
}
function Show_user()
{
var i;
for(i=document.form1.chat_user.options.length;i>0;i--)
{
document.form1.chat_user.options.remove(i-1);
}
document.form1.chat_user.options.add(new Option("所有人",278810));
i = user.length-1;
while(i>=0)
{
if (user[i]==myroomid || myroomid==0)
{
document.form1.chat_user.options.add(new Option(user[i-1],user[i-2]));
}
i -=3;
}
document.form1.chat_user.selectedIndex = myroomid;
}
function Load_log()
{
var value=GetPage("chat_log.asp?id="+pid);
var str = value.split("#");
var id,roomid,msgBody;
var i=str.length-1;
while(i-- >0)
{
temp = str[i].split("*");
id = temp[0];
roomid = temp[1];
msgBody = temp[2];
log.push(roomid,msgBody);
pid = id;
}
if (str.length>1)
{
Show_log();
}
t_log = setTimeout("Load_log();",5000);
}
function Show_log()
{
var i=log.length-1;
var str="";
while(i>=0)
{
if (log[i-1]==myroomid || myroomid==0)
{
str += log[i].toString() + "\n";
}
i -=2;
}
document.form1.log.value = str;
}
function Change_room()
{
myroomid=document.form1.chat_room.selectedIndex;
//clearTimeout(t_room);
//clearTimeout(t_user);
//clearTimeout(t_log);
Show_room();
Show_user();
Show_log();
}
function Send()
{
var Body = "content=" + escape(document.form1.content.value) + "&srcphone=" + escape(srcphone);
//Body = escape(Body);
PostData("chat_send.asp",Body);
//GetPage("chat_send.asp?"+Body);
document.form1.content.value = "";
document.form1.content.Focus();
}
iuhxq 2004-09-24
  • 打赏
  • 举报
回复
俺正巧也做聊天程序
首页:index.asp
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!--#include file="conn.asp"-->
<!--#include file="chklogin.asp"-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">
<title>聊天室</title>
<link href="style.css" rel="stylesheet" type="text/css">
</head>

<body>

<script language="javascript">
var t_room,t_log,t_user;
var phone,srcphone,province,content;
var room,log,user,myroomid=0,pid;
log = Array();
user = Array();
<%
set rs=conn.execute("select top 1 chat_id as id from chat_log where chat_id in (select top 50 chat_id from chat_log order by chat_id desc) order by chat_id")
response.Write("pid="&rs("id")&";")
%>
</script>
<script language="javascript" src="function.js"></script>
<form name="form1" method="post" action="" onSubmit="return false;">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="11%" valign="top"><div align="center">
<select id="chat_room" onChange="Change_room();"></select><br>
<select id="chat_user" name="select" size="30" onChange="srcphone = this.value;"></select><br>
<span onClick="Load_room();" style="cursor:hand;">刷新房间列表</span><br>
<span onClick="Load_user();" style="cursor:hand;">刷新用户列表</span></div></td>
<td width="89%" valign="top"><textarea name="log" rows="35" wrap="VIRTUAL" id="log"></textarea></td>
</tr>
<tr>
<td> </td>
<td><input name="content" type="text" id="content" size="100" maxlength="140" onKeyDown="if (event.keyCode==13) {Send();}">
<input name="SendToServer" type="button" id="SendToServer" onClick="Send();" value="发送">
<input type="button" name="Submit" value="退出" onClick="window.location.href='logout.asp';"></td>
</tr>
</table>
</form>
</body>
</html>
时光888 2004-09-24
  • 打赏
  • 举报
回复
不是很明白,刚学ASP不久
whnnet 2004-09-24
  • 打赏
  • 举报
回复
http://blog.csdn.net/net_lover/archive/2004/07/06/35220.aspx
whnnet 2004-09-24
  • 打赏
  • 举报
回复
<meta http-equiv=refresh content="5">
即可

最好用xmlhttp

28,390

社区成员

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

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