我有一个“加载页面”,用于提示用户系统正在搜索。
当用户按下返回按钮时,我想跳过此页面并将其重定向到第一页。
如何实现? 谢谢。
如何实现? 谢谢。
我刚刚使用了 windows.location.replace(newUrl)
,它可以将页面从历史记录中移除并修复它。
你可以在加载页面检查引荐来源并匹配。如果引荐来源是“后续”加载页面的页面,那么可以假定用户按了返回按钮。
你可以在服务器端或javascript中实现此功能,以下是JS的示例(伪代码):
if ( document.referrer.test(/[URL]/) ) {
window.location = '/';
}
<%
Response.Buffer = True
Response.ExpiresAbsolute = Now() - 1
Response.Expires = 0
Response.CacheControl = "no-cache"
If Len(Session("FirstTimeToPage")) > 0 then
'The user has come back to this page after having visited
'it... wipe out the session variable and redirect them back
'to the login page
Session("FirstTimeToPage") = ""
Response.Redirect "/Bar.asp"
Response.End
End If
%>