asp学习网: 首页 >> asp对象 >> session对象 >> ASP禁止刷新当前页

ASP禁止刷新当前页

防止用户频繁刷新页面,可以起到一点点的作用。

方法1,session技术:
 程序代码
<% 
Dim SplitReflashPage 
Dim DoReflashPage 
dim shuaxin_time 
DoReflashPage=true 
shuaxin_time=10 
ReflashTime=Now() 
if (not isnull(session("ReflashTime"))) and cint(shuaxin_time)>0 and DoReflashPage then 
if DateDiff("s",session("ReflashTime"),Now())<cint(shuaxin_time) then 
response.write "<META http-equiv=Content-Type content=text/html; charset=gb2312><meta HTTP-EQUIV=REFRESH CONTENT=3>本页面起用了防刷新机制,请不要在<b><font color=ff0000>"&shuaxin_time&"</font></b>秒内连续刷新本页面<BR>正在打开页面,请稍候……" 
response.end 
else 
session("ReflashTime")=Now() 
end if 
elseif isnull(session("ReflashTime")) and cint(shuaxin_time)>0 and DoReflashPage then 
Session("ReflashTime")=Now() 
end if 
randomize timer 
regjm=int(rnd*8998)+1000 
%> 


方法2,cookie技术:
 程序代码
<% 
Dim URL 
If DateDiff("s",Request.Cookies("oesun")("vitistime"),Now())<2 Then 
URL=Request.ServerVariables("Http_REFERER") 
Response.Write("<meta http-equiv=""refresh"" content=""2;URL="&URL&""">") 
Response.Write("防刷新,两秒后自动跳转") 
Response.End 
End IF 
Response.Cookies("oesun")("vitistime")=Now() 
%> 
aspxuexi.com,asp学习网整理文档,转载请标记出处。
主要的作用是放置表单的错误重复提交,参看:http://www.aspxuexi.com/forms/2006-5-28/616.htm
大家用的时候融会贯通吧。
from:asp学习网/title:ASP禁止刷新当前页/ time:2007-1-29 13:41:49

本文主题ASP禁止刷新当前页

asp教程 ©2006-2007 aspxuexi.com | 关于站点 | 版权隐私 | 站内搜索
复制或者翻版 请于夜间进行