views:

2605

answers:

4

Duplicate:


I have to disable back and forward button of browser ( IE and Firefox both ). I have tried:

//disable back button
window.onbeforeunload= function() { } 
window.history.forward(1);

but this works only in IE.
Is there any foolproof solution?

+3  A: 

There is no solution for that problem. You can't really "disable" it.

Martin K.
+11  A: 

The answer is "no". You cannot disable a browser's back button.

Or at least on a good browser.

zombat
+8  A: 

I believe this question has already been asked:

http://stackoverflow.com/questions/87422/disabling-back-button-on-the-browser http://stackoverflow.com/questions/54539/prevent-use-of-the-back-button-in-ie

If you're trying to prevent the user from losing their work, try something like:

window.onbeforeunload = function() { return "You work will be lost."; };

Steve

Steve Harrison
yes we can usewindow.onbeforeunload= function() { return "so you want to go."; }, this will show wht you are saying. But i really don't want this thing.
+1  A: 

I would argue you should not disable the back button it at all possible as users are used to using it and it will frustrate them to find its functionality removed.

The users flow will be interrupted and they will leave your site.

Paul Whelan