禁用浏览器后退按钮 [英] Disabling browser back button

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

问题描述

我使用以下代码禁用了浏览器的后退按钮,但该按钮仍在工作.请帮我

I used the following code to disable my browser back button but button is still working. plz help me out

Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetExpires(DateTime.UtcNow.AddHours(-1));
Response.Cache.SetNoStore();

推荐答案

请参阅:

如何禁用浏览器的后退按钮 [ ^ ]
Refer this:

How to disable browser''s back button[^]


您好

您可以使用以下javascript ...来限制用户返回Backspace键.


Hi

you can restrict the user to go back with Backspace key by using following javascript...


<script type="text/javascript" language="javascript">
    function cancelBack()   
    {   
        if ((event.keyCode == 8 ||    
           (event.keyCode == 37 && event.altKey) ||    
           (event.keyCode == 39 && event.altKey))   
            &&    
           (event.srcElement.form == null || event.srcElement.isTextEdit == false)   
          )   
        {   
            event.cancelBubble = true;   
            event.returnValue = false;   
        }   
        
        if (window.event.keyCode == 13) 
        {
            event.returnValue=false; 
            event.cancel = true;
        }
    }   
    </script>


检查此
注销后浏览器后退按钮问题 [
Check this
Browser back button issue after logout[^]


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

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