我已经注释了,大家不明白可以看注释
<html>
<head>
</head>
<body>
<%
'1,If Request.ServerVariables("Request_Method")="GET" then的作用就是判断当前页面接受的方式,如果为GET方式则会显示“要求输入昵称”的表单页。因为页面的默然接受方式为GET,当在URL地址栏直接敲入时,也就是没有任何信息的时候,就应该显示要求“输入昵称”。
'2,<input type="hidden" name="log" size="20" value="1">和下面的If Request.Form("log")<>1 then是有关联的:显然第一次输入昵称进入,同样将log隐藏域发送。但作为第一次的进入是无任何语句发言的,所以判断接受的log值不为1,亦即非首次登录(表示已经登录)时,执行内部相关聊天显示程序。
'3,trim(Request.Form("talk"))="",trim就是个函数了:删去字符串前,后的空格。初此,还有rtrim():去掉字符串后的空格;ltrim():去掉字符串前的空格。
'4.Application变量的叠加功能,每次Application("show")的值都建立在原有Application变量值的基础之上,再附加上最新的聊天内容:talk变量的值。这样就保证所有用户都能看到的共享信息了。
If Request.ServerVariables("Request_Method")="GET" then%>
<form method="post" action="">
你的名字<input name=nick><input type=submit value=进入>
</form>
<%
Else
Response.clear
dim talk
If Request.Form("nick")<>"" then
Session("nick")=Request.Form("nick")
End if
%>
<form method=post action="" name=form1>我 <%=Session("nick")%> 要说:
<input name="talk"><input type="submit" value="提交"><a href="chat.asp">离开</a><hr></form>
<%
If Request.Form("log")<>1 then
If trim(Request.Form("talk"))="" then
talk=Session("nick")&"不说一句话就想来敷衍大家"
Else
talk=trim(Request.Form("talk"))
End If
Application.lock
Application("show")="<a title="&Request.ServerVariables("remote_addr")&">"&Session("nick")&" "&time&"<br>"&talk&"<br>"&Application("show")
Application.UnLock
Response.Write Application("show")
End if
End if%>
<hr>
<%=year(now)%>年<%=month(now)%>月<%=day(now)%>日<%=hour(now)%>点<%=time%>
</body>
</html>
<style>
html,td,input{font-size:12px;background:#000000;color:#fff;border:1px solid #666666}
</style>
<html>
<head>
</head>
<body>
<%
'1,If Request.ServerVariables("Request_Method")="GET" then的作用就是判断当前页面接受的方式,如果为GET方式则会显示“要求输入昵称”的表单页。因为页面的默然接受方式为GET,当在URL地址栏直接敲入时,也就是没有任何信息的时候,就应该显示要求“输入昵称”。
'2,<input type="hidden" name="log" size="20" value="1">和下面的If Request.Form("log")<>1 then是有关联的:显然第一次输入昵称进入,同样将log隐藏域发送。但作为第一次的进入是无任何语句发言的,所以判断接受的log值不为1,亦即非首次登录(表示已经登录)时,执行内部相关聊天显示程序。
'3,trim(Request.Form("talk"))="",trim就是个函数了:删去字符串前,后的空格。初此,还有rtrim():去掉字符串后的空格;ltrim():去掉字符串前的空格。
'4.Application变量的叠加功能,每次Application("show")的值都建立在原有Application变量值的基础之上,再附加上最新的聊天内容:talk变量的值。这样就保证所有用户都能看到的共享信息了。
If Request.ServerVariables("Request_Method")="GET" then%>
<form method="post" action="">
你的名字<input name=nick><input type=submit value=进入>
</form>
<%
Else
Response.clear
dim talk
If Request.Form("nick")<>"" then
Session("nick")=Request.Form("nick")
End if
%>
<form method=post action="" name=form1>我 <%=Session("nick")%> 要说:
<input name="talk"><input type="submit" value="提交"><a href="chat.asp">离开</a><hr></form>
<%
If Request.Form("log")<>1 then
If trim(Request.Form("talk"))="" then
talk=Session("nick")&"不说一句话就想来敷衍大家"
Else
talk=trim(Request.Form("talk"))
End If
Application.lock
Application("show")="<a title="&Request.ServerVariables("remote_addr")&">"&Session("nick")&" "&time&"<br>"&talk&"<br>"&Application("show")
Application.UnLock
Response.Write Application("show")
End if
End if%>
<hr>
<%=year(now)%>年<%=month(now)%>月<%=day(now)%>日<%=hour(now)%>点<%=time%>
</body>
</html>
<style>
html,td,input{font-size:12px;background:#000000;color:#fff;border:1px solid #666666}
</style>