按下后退按钮上的重定向页面

时间:2013-10-17 09:45:44

标签: javascript asp.net web

我有一个“加载页面”来指示系统正在搜索的用户。 我想在用户按下后退按钮并将他重新定位到第一页时跳过此页面。

怎么做? 感谢。

3 个答案:

答案 0 :(得分:2)

我刚刚使用了windows.location.replace(newUrl),它从历史记录中删除了页面并修复了它。

答案 1 :(得分:0)

您可以检查引荐来源并在加载页面上进行匹配。如果引荐来源是加载页面“之后”页面的页面,则可以假定用户已按下该页面。

您可以在服务器上或javascript中执行此操作,在JS中执行示例(伪):

if ( document.referrer.test(/[URL]/) ) {
    window.location = '/';
}

答案 2 :(得分:-2)

使用javascript

Response.Cache.SetNoStore();或window.history.forward(1);

这将禁用后退按钮功能。还有一些会话值,如果单击后退按钮,将设置为空。喜欢下面的一个。

<%
  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
%>