Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-13-2003, 11:01 PM   PM User | #1
michael.hd
New Coder

 
Join Date: May 2003
Location: UK
Posts: 68
Thanks: 0
Thanked 0 Times in 0 Posts
michael.hd is an unknown quantity at this point
disable back button in opera

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...

window.history.forward();
or

window.history.go(1);

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
submitted=true;
}

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
__________________
They only tell you its a stupid question when they don't know the answer!
michael.hd is offline   Reply With Quote
Old 10-14-2003, 10:22 AM   PM User | #2
zoobie
Senior Coder

 
Join Date: Jun 2002
Location: ColoRockyz
Posts: 1,642
Thanks: 1
Thanked 0 Times in 0 Posts
zoobie has a little shameless behaviour in the past
Re: disable back button in opera

Quote:
Originally posted by michael.hd
You see I am trying to protect newbies to the web from themselves!!!
I'm afraid that's impossible.
You have something against Fred's browser?
__________________
Zoobie or not Zoobie...That is the problem.
<body onUnload="flush( ! )">
zoobie is offline   Reply With Quote
Old 10-14-2003, 02:54 PM   PM User | #3
Roy Sinclair
Senior Coder

 
Join Date: Jun 2002
Location: Wichita
Posts: 3,880
Thanks: 0
Thanked 0 Times in 0 Posts
Roy Sinclair will become famous soon enough
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.
__________________
Check out the Forum Search. It's the short path to getting great results from this forum.
Roy Sinclair is offline   Reply With Quote
Old 10-14-2003, 05:33 PM   PM User | #4
michael.hd
New Coder

 
Join Date: May 2003
Location: UK
Posts: 68
Thanks: 0
Thanked 0 Times in 0 Posts
michael.hd is an unknown quantity at this point
Thanks, but not what I needed

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.
__________________
They only tell you its a stupid question when they don't know the answer!
michael.hd is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:23 PM.


Advertisement
Log in to turn off these ads.