禁用浏览器后退按钮

禁用浏览器后退按钮

问题描述:

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

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[^]