View Full Version : disable back button in opera

10-14-2003, 12:01 AM
Yes it's that disable back button thing again.

For all those about to tell me to leave it alone - don't bother. I am not trying to restrict the pleasure or freedom of my users.

After registering on my site users are asked to log-in. If they press the back button (why I don't know) they will return to the registration process. Resubmitting old forms will cause errors to appear such as...

"This username already exists" - of course it does YOU just registered it. You see I am trying to protect newbies to the web from themselves!!!

Ths solution is to add this script...



both work excellently in IE6, but neither works in Opera. Does anyone know a workaround.

In Opera I protect my visitors by adding the following code to my javascript form validation...

var submitted = false;

function validate()
if (submitted == true)
alert("This form has already been submitted. \nPlease press Ok and wait for this process to be completed.");
return false;
etc etc

This prevents the user from resubmitting the form. However I can't get this to work in IE6!!!

Wouldn't it be nice if both browsers could work the same.

Does anyone know a method which will work in both.

Thank you in advance

10-14-2003, 11:22 AM
Originally posted by michael.hd
You see I am trying to protect newbies to the web from themselves!!!

I'm afraid that's impossible. :p
You have something against Fred's browser? :D

Roy Sinclair
10-14-2003, 03:54 PM
If Opera doesn't reset the state of the page when the user "backs" into it you can set a variable when the page is submitted and then refuse to submit it again if the variable has the already submitted value. That would protect you against more than just Opera but the downside is that anyone with Javascript disabled would be able to bypass your checks.

Another possibility is to assign each page to be submitted a unique identifier in a hidden field and keep that identifier for a period of time after any page is submitted, if you see it come in again you simply reject the submission. That requires server side code and is definitely more complex but it's also more user-resistant.

10-14-2003, 06:33 PM
Thanks for your help and advice.

the fact is that I do have variables in the server side code to protect me (the web owner) from the user.

I am trying to avoid the situation where the user gets error messages saying that the page has already been submitted etc. For some reason this seems to freak them out and they think the site is broken!

If they just could not go back this would be best. Also when they exit the payment area (I use worldpay) and return to my site, I want to prevent them going back and paying again etc. Refunds take time and cost me money!

This is one time I wish all browsers worked like IE6. If I could get opera to emulate that history.forward() it would be great.

I know most people use IE but I don't want to be ever guilty of dumping those crusading few who dare to be different.

Does anyone know of a site that provides example code of how to make things work in opera? - Actually scrap that! I will post that as a new question.

But still if possible any more help on original question please.