Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    May 2003
    Location
    UK
    Posts
    68
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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!

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    ColoRockyz
    Posts
    1,646
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: disable back button in opera

    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( ! )">

  • #3
    Senior Coder
    Join Date
    Jun 2002
    Location
    Wichita
    Posts
    3,880
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #4
    New Coder
    Join Date
    May 2003
    Location
    UK
    Posts
    68
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •