25

Firefox has a very annoying feature. It remembers the state of input fields when you hit F5. It's not just the value, it remembers even whether the input is disabled or not.

Example:

<html>
    <head>
         <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"></script>
    </head>
    <body>
        <input type="text" value="textbox" />
        <a href="#" onclick="javascript: $('input').attr('disabled', true); return false; " >Disable text box</a>
    </body>
</html>

The code above has an anchor that, when clicked, disables the text input field. After that, Firefox will remember the state after F5 and the only way to restore it to the original is to hit enter on the address bar.

Is there a meta tag or something to make FF stop doing that?

EDIT

Actually browsers have different behaviors. Firefox is the most annoying. Firefox remembers the input value and whether it's disabled or not. IE8 remembers the value and Chrome doesn't remember anything

Andre Pena
  • 56,650
  • 48
  • 196
  • 243

4 Answers4

31

You can set the element or the form to autocomplete="off" to disable state preservation, but that also disables input autocomplete, of course.

Kissaki
  • 8,810
  • 5
  • 40
  • 42
Boris Zbarsky
  • 34,758
  • 5
  • 52
  • 55
2

I do think all browsers have that feature.

But to reset your input to its original value, try this.

$('document').ready(function(){//or whenever you want to fire back to the default value
    $('input#withanidplease').val($('input#withanidplease').prop('defaultValue'))
})
Fredy31
  • 2,660
  • 6
  • 29
  • 54
  • Actually browsers have different behaviors. Firefox is the most annoying. Firefox remembers the input value and whether it's disabled or not. IE8 remembers the value and Chrome doesn't remember anything. Thank you for your reply but I'm really after a solution that does't involve JavaScript – Andre Pena Nov 29 '11 at 13:37
  • Ok. For common knowledge: No javascript, or no JQuery? because in your example you use some Javascript. – Fredy31 Nov 29 '11 at 13:48
-3

try this:

<a href="javascript:void(0)" onclick="javascript: $('input').attr('disabled', true); return false; " >Disable text box</a>
Waqas Mehmood
  • 135
  • 1
  • 1
  • 7
-3

Based on the scripting language you are using, you may try to disable caching.

user935581
  • 17
  • 5