ASP禁止刷新当前页

博客介绍了ASP实现页面防刷新的两种方法。方法1利用Session和时间差判断,若在设定时间内刷新则提示等待;方法2通过Cookies记录访问时间,若短时间内刷新则自动跳转。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

方法1:
<%  
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:
<%  
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()  
%
>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值