热门文章
 
ASP内建对象Server
Global.asa文件的使
ASP内建对象Applica
访问和更新Cookies集合
Asp:Cookie集合 简
asp中cookie使用示例
Asp:Cookie集合简介
遍历cookies的方法
判断cookie是否开启
cookies读写基本例子
 推荐文章
 
ASP Session 对象
松子谈asp的Request
再总结一下asp重定向的方法
asp:Session St
session的使用与性能:
asp session 使用
asp中session具体是
防止ASP Session丢
Asp提高首页性能的一个技巧
ASP禁止刷新当前页
asp清空session 关
TypeLibrary 声明
cookies和sessio
web开发:Session详
ASP中Session技巧
再谈asp中的Server.
 
你现在的位置:您现在的位置是: 中国ASP>>ASP教程>>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/aspbasic/responseandrequest/2006-4-27/asp_CacheControl.htm
主要的作用是放置表单的错误重复提交,参看:http://www.aspxuexi.com/forms/2006-5-28/616.htm
大家用的时候融会贯通吧。

相关信息:

ASP内建对象Application和Session
Cookie,Session,Application封装
Session与Cookie区别
再谈cookies和session的关系
罗列全部session和application
ASP的Application对象和Session对象
创建Variant数组
ASP中使用Session变量的优缺点
计算session和application的数量

 

中国ASP技术 ASP.ORG.CN 版权所有 2004-2008