1. Kage Bunshin
    Devshed Novice (500 - 999 posts)

    Join Date
    Aug 2005
    The Seven Seas Of Rhye
    Rep Power

    Firefox Refresh on Back

    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? Here is basically what my code boils down to:
    <SCRIPT language="JavaScript" type="text/javascript">
        var img;
        var name;
        function preloader() {
            img = new Image();
            name = "CAPTCHA.php?rand=" + rand();
            img.src = name;
        function refresh() {
            document.images["CAPTCHA"].src = name;
        function rand() {
            var random = "" + Math.random();
            return random.replace(/\./, "")
        function submitForm() {
        <a onClick="javascript:refresh()">
           <img width="120" height="40" name="CAPTCHA" src="CAPTCHA.php" alt="Click to refresh">
        <form name="test" method="post" action="test.php">
              <input type="button" onClick="javascript:submitForm()" value="Click Me">
    Last edited by tagmanadvance; February 22nd, 2008 at 02:18 PM.
    "Java makes impossible things possible, but makes easy things difficult." - Somebody

IMN logo majestic logo threadwatch logo seochat tools logo