84

When I refresh a page with Firefox, the values of the check boxes, input fields, etc. are kept.

Is there a way to make Firefox not keep them, using a meta tag without JavaScript?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Nir
  • 3,963
  • 8
  • 37
  • 51
  • Is this for your own web page or for any web page? – Gumbo Mar 21 '10 at 09:16
  • Possible duplicate of [Make page to tell browser not to cache/preserve input values](http://stackoverflow.com/questions/2699284/make-page-to-tell-browser-not-to-cache-preserve-input-values) – user Jun 04 '16 at 00:57
  • 1
    Please switch to a Chromium based browser. Firefox knows about this since 21 years, and they are not able or unwilling to behave like Chrome or Safari: https://bugzilla.mozilla.org/show_bug.cgi?id=46845#c232 – guettli Jul 14 '21 at 08:49
  • See [html - Bug With Firefox - Disabled Attribute of Input Not Resetting When Refreshing - q/5985839](https://stackoverflow.com/q/5985839). – li ki Mar 28 '22 at 17:18

3 Answers3

173

For an input tag there's the attribute autocomplete you can set:

<input type="text" autocomplete="off" />

You can use autocomplete for a form too.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
True Soft
  • 8,675
  • 6
  • 54
  • 83
  • 3
    This is part of HTML5 now and supported by all major browsers on `` except Opera doesn't do the `
    ` tag.
    – Aaron D. Marasco Aug 09 '12 at 00:41
  • For reference [https://developer.mozilla.org/en-US/docs/Mozilla/How_to_Turn_Off_Form_Autocompletion](https://developer.mozilla.org/en-US/docs/Mozilla/How_to_Turn_Off_Form_Autocompletion) – Planky Apr 03 '13 at 18:32
  • 20
    @AaronD.Marasco Turning auto-complete off may also prevent Firefox from remembering input values between page reloads, but it's a valuable feature over and above remembering input values between reloads. The question was, how to stop Firefox from remembering input values between page reloads, not how to disable autocomplete. – Mr. TA Aug 26 '13 at 10:30
  • @Mr TA... true: I suppose the answer is to use jQuery to explicitly reset the values of all INPUTs etc. on reload... I experience a very strange phenomenon with FF currently: with each reload the contents of one INPUT is "bumped along" to the next INPUT. This only happens when I have an injected – mike rodent Jul 31 '14 at 08:30
  • This is a good solution and also works for input type 'range'. – Vijayendra Jul 16 '22 at 15:36
3

If you want to prevent remembering field values after reload, while still getting to use autocomplete:

First define autocomplete off in the markup:

<input id="the-input" type="text" autocomplete="off" />

Then re-enable autocomplete programatically:

document.getElementById('the-input').autocomplete = 'on';

this will disable autocomplete just at the right time when the page loads and re-enable it so it can be used (but the field value will be empty as it should).

If it does not work for you, try wrapping the js code in a setTimeout or requestAnimationFrame.

Maciej Krawczyk
  • 14,825
  • 5
  • 55
  • 67
1
// Internet Explorer fix - do this at the end of the page
var oninit_async_reset = setInterval(function() { resetFormIEFix(); }, 500);
function resetFormIEFix() {
    $('#inputid').val('');
    if (typeof oninit_async_reset != 'undefined')
        clearInterval(oninit_async_reset);
}
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131