如何阻止浏览器后退按钮.... [英] how to block browser back button....

查看:191
本文介绍了如何阻止浏览器后退按钮....的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





i希望阻止那些浏览器使用不同版本的IE浏览器:10 +,firefox ver:30 +,chrome ver:35 + 。



i在javascript中尝试了一些无法正常工作的代码。下面的代码如下:



example1:< pre lang =text> javascript:window.history.forward(1);



例2:



< script type =text / javascript> 

函数preventBack(){window.history.forward();}

setTimeout(preventBack(),0);

window.onunload = function(){null};

< / script>







请给出一些好的解决方案这个asap。

解决方案

参考:



http://viralpatel.net/blogs/disable-back-button-browser-javascript/ [ ^ ]






您可以尝试的另一件事是使用以下代码清除,假设您的是mvc应用程序



  public   class  NoCache:ActionFilterAttribute 
{
public 覆盖 void OnResultExecuting(ResultExecutingContext filterContext )
{
filterContext.HttpContext.Response.Cache.SetExpires(DateTime.UtcNow.AddDays(-1));
filterContext.HttpContext.Response.Cache.SetValidUntilExpires( false );
filterContext.HttpContext.Response.Cache.SetRevalidation(HttpCacheRevalidation.AllCaches);
filterContext.HttpContext.Response.Cache.SetCacheability(HttpCacheability.NoCache);
filterContext.HttpContext.Response.Cache.SetNoStore();
}
}


Windows转发 [ ^ ]

操纵浏览器历史记录 [ ^ ]

禁用浏览器后退按钮,您不应该或者说不能。检查我提供的链接。这些仅仅是浏览器历史记录,让您感觉后退按钮被禁用但不完全。

Window.History.Forward()是一个简单的。这会阻止用户返回上一页。第二个链接可以帮助您找到更多操作方法。

希望这会有所帮助。

回复您的查询(如果有的话)。

谢谢。

:)


Hi,

i want to block back button in those browsers with different version like IE ver:10 +,firefox ver:30 + ,chrome ver: 35 +.

i tried some code in javascript that will not work.here code below:

example1 :

javascript:window.history.forward(1);


example 2 :

<script type = "text/javascript" >

   function preventBack(){window.history.forward();}

    setTimeout("preventBack()", 0);

    window.onunload=function(){null};

</script>




pls give some good solution for this asap.

解决方案

Refer this :

http://viralpatel.net/blogs/disable-back-button-browser-javascript/[^]


Hi,

The other thing that you can try is clear the with the following code assuming that yours is an mvc application

public class NoCache : ActionFilterAttribute
  {
      public override void OnResultExecuting(ResultExecutingContext filterContext)
      {
          filterContext.HttpContext.Response.Cache.SetExpires(DateTime.UtcNow.AddDays(-1));
          filterContext.HttpContext.Response.Cache.SetValidUntilExpires(false);
          filterContext.HttpContext.Response.Cache.SetRevalidation(HttpCacheRevalidation.AllCaches);
          filterContext.HttpContext.Response.Cache.SetCacheability(HttpCacheability.NoCache);
          filterContext.HttpContext.Response.Cache.SetNoStore();
      }
  }


Windows Forward[^]
Manipulate Browser History[^]
Disabling browser back button, you should not or say you cannot. Check the links I have provided. These just maipulate with the browsers history letting you feel the Back button is disabled but not exactly.
Window.History.Forward() is a simple one. Which prevents the user going back to previous page. The second link helps you find more methods to manipulate on this.
Hope this helps.
Post back your queries if any.
Thanks.
:)


这篇关于如何阻止浏览器后退按钮....的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆