Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    Join Date
    Feb 2004
    Location
    India
    Posts
    135

    Unanswered: Disable Back Button

    hi all,

    how to disable browser's back button...

    for example:

    i am in first.asp and then i am going to second.asp by pressing submit button.here, u can see browser's back button will be enabled.....

    but, what i need is ,
    in second.asp page ....i should not see back button will enable....

    so plz give code,how to disable browser's back button.....

  2. #2
    Join Date
    Nov 2003
    Location
    Christchurch, New Zealand
    Posts
    1,618
    can't do it.... full stop. end of story, thanks for playing

  3. #3
    Join Date
    Feb 2004
    Location
    India
    Posts
    135
    No. its possible man.

  4. #4
    Join Date
    Dec 2003
    Posts
    454
    Close your browser of your first page and open the new one for your second page.

  5. #5
    Join Date
    Jun 2003
    Location
    USA
    Posts
    1,032
    A1ien51's disable the Back Button
    http://www10.brinkster.com/A1ien51/S...BackButton.htm
    What is going to happen, is when the page loads, it will send the surfer to the last page in their history.
    Now if a person tries to go back to it, then it will send them directly back to the page they pushed the back button on!
    Add this code to the header of your page:
    <script>
    history.forward();
    </script>

    JPS: Thus need to put the code on the page you don't want the user to be able to go back to.
    And here is my version of it:
    <script type="text/javascript"> <!--
    // Disable browser's Back button on another pg being able to go back to this pg.
    history.forward();
    //-->
    </script>
    J. Paul Schmidt, Freelance Web and Database Developer
    www.Bullschmidt.com
    Access Database Sample, Web Database Sample, ASP Design Tips

  6. #6
    Join Date
    Feb 2004
    Location
    India
    Posts
    135
    thanx schmidt.

    it works

  7. #7
    Join Date
    Nov 2003
    Location
    Christchurch, New Zealand
    Posts
    1,618
    it'll only work if they press the back button once. Pressing it multiple times will return them eventually to a page without this code. So techincally you have disabled it at all...

  8. #8
    Join Date
    Jun 2003
    Location
    USA
    Posts
    1,032
    <<
    it'll only work if they press the back button once. Pressing it multiple times will return them eventually to a page without this code. So techincally you have disabled it at all...
    >>

    I just tested clicking on the browser's Back button multiple times on some of my pages that actually use this feature and the back button WAS effectively disabled.
    J. Paul Schmidt, Freelance Web and Database Developer
    www.Bullschmidt.com
    Access Database Sample, Web Database Sample, ASP Design Tips

  9. #9
    Join Date
    Nov 2003
    Location
    Christchurch, New Zealand
    Posts
    1,618
    Well I have tried it here and can easily leap back pages... of course it could be due to a slow connection speed due to dial up....

    I'm not trying to knock the solution, I think it is the best you will get. I just want the guy to be aware that in essence it's not completely disabled...

    Personally I can't understand why you would want to do something like that in the first place.
    Last edited by rokslide; 03-14-04 at 16:36.

  10. #10
    Join Date
    Jun 2003
    Location
    USA
    Posts
    1,032
    <<
    Personally I can't understand why you would want to do something like that in the first place.
    >>

    Well I've used it for a confirmation page where a user just registered something and I don't want the user to just use the browser's back button to go back and change the last page (or pages before that) and in effect submit another registration...
    J. Paul Schmidt, Freelance Web and Database Developer
    www.Bullschmidt.com
    Access Database Sample, Web Database Sample, ASP Design Tips

  11. #11
    Join Date
    Nov 2003
    Location
    Christchurch, New Zealand
    Posts
    1,618
    In that case I'd disable the button that submits the the registration, not the back button.

  12. #12
    Join Date
    Dec 2003
    Posts
    454
    If the user types and hits the url on the browser the registration form will be submitted again. You can use session variable to prevent the user from double submit of the form.

  13. #13
    Join Date
    Nov 2003
    Location
    Christchurch, New Zealand
    Posts
    1,618
    Yup, depending on how the form can be submitted there are various ways to prevent the multiple submitting.... disabling the back button IMO is a cop out for doing the job properly... not trying to be rude or anything...

  14. #14
    Join Date
    Jun 2003
    Location
    USA
    Posts
    1,032
    <<
    If the user types and hits the url on the browser the registration form will be submitted again. You can use session variable to prevent the user from double submit of the form.
    >>

    Yes, session variables can and are being checked everytime a page is opened to make sure someone can't get in (again) if you don't want him too.

    But the browser's back button is sort of a "loophole" to still allow the user back to a page you don't want him on anymore. For example even after a session times out a user can still hit the browser's back button and get onto a session variable protected page.

    The code above keeps this from happening and works very well for this admittedly limited use purpose.

    In other words I don't use this code very often but there are some times when it does come in handy.
    J. Paul Schmidt, Freelance Web and Database Developer
    www.Bullschmidt.com
    Access Database Sample, Web Database Sample, ASP Design Tips

  15. #15
    Join Date
    Nov 2003
    Location
    Christchurch, New Zealand
    Posts
    1,618
    Yeah, I can see that it would be kinda handy, but I wouldn't use it as a "this will stop them submitting multiple requests" solution.

Posting Permissions

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