Firefox Refresh Captcha on Back

Discussion in 'Programming' started by Foxch, Jun 30, 2008.

  1. #1
    I have a page with a form which uses a captcha. This all works great, except when the user clicks their backbutton in firefox. They get back to the form ok, but the old (used) captcha image is still there. For some reason, firefox doesn't refresh when the back button is pressed. I thought that if I used javascript to refresh the image that might solve the problem, but apparently firefox doesn't execute javascript when the back button is pressed either. I finally worked out a system where it changes the image when the submit button is clicked, but it doesn't work all the time. Can someone please help me refresh my captcha when the back button is pressed in firefox?
    Thanks a lot.
     
    Foxch, Jun 30, 2008 IP
  2. AliasXNeo

    AliasXNeo Banned

    Messages:
    151
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You can attempt to prevent FireFox from caching that page:

    <?php
    header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
    header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
    ?>
    
    Code (markup):
    See PHP documentation for header() for more information.
     
    AliasXNeo, Jun 30, 2008 IP
  3. Foxch

    Foxch Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    THX AliasXNeo
    My captcha.php used no-cache,But another php file used session_cache_limiter() function to keep user's input when validate fail and window.history.back(),it's incompatible...
    To resolve this,I have to use
    <input name="captcha" onfocus="if(isFF) reloadcaptcha();"
    Code (markup):
    But still, Not perfect...
     
    Foxch, Jul 1, 2008 IP