Click here to Skip to main content
16,015,531 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
To prevent the users from going to the previous page, i have been using the javascript function as follows
XML
<script type"text/javascript">        
       function DisableBackButton() {
            window.history.forward()
        }
        DisableBackButton();
        window.onload = DisableBackButton;
        window.onpageshow = function (evt) { if (evt.persisted) DisableBackButton() }
        window.onunload = function () { void (0) }
<script>


It has been working satisfactorily in ie9

Now i fiind that in chrome and Firefx, it fails to prevent users from using back button.

I am looking for modification in code or some other code that can prevent users from using back button

I am not talking of disabling back button on logout but it is all about using back button on pages within the site, which is necessitated because of change in role when user goes from one page to other.

Any kind of help would be welcome

Many thanks
Posted
Updated 9-Mar-14 8:07am
v2

Test the following lines :
JavaScript
<script type = "text/javascript" >
    function preventBack(){window.history.forward();}
    setTimeout("preventBack()", 0);
    window.onunload=function(){null};
</script>

View the below link too :
[http://www.sawtoothsoftware.com/forum/1854/disabling-browser-back-button-chrome-previous-button[^]]
 
Share this answer
 
v2
Comments
Member 10235977 10-Mar-14 10:49am    
It worked in Firefox but it did not work in Chrome
Try

Disable-Browser-Back-Button-Functionality-using-JavaScript[^]

The demo seems to be working in Chrome when I tried.
 
Share this answer
 
Comments
Member 10235977 10-Mar-14 10:50am    
It worked in Firefox but it did not work in Chrome

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900