[Javascript] Slightly OT: Auto re-fill of form elements on browser Back button.

Peter-Paul Koch pp.koch at gmail.com
Wed Oct 6 08:21:29 CDT 2004


> As most of you probably experienced at one point or another, browsers
> tend to keep the filled in values of form elements if you submit the
> form and then hit the Back-button to go back to the form again. This
> might be convenient in most cases, but I need to be able to control
> this, and reset the values to their default values whenever the form is
> "reloaded" in any way.
> 
> My questions is; Do anybody know of the exact criteria for this
> auto-refill to happen? Is it only when you go back or is it simply a
> question of caching on the browsers behalf?

As far as I know this is a native browser function; and the exact
implementation differs per browser.

> Turning the feature off through the browser or sending HTTP-headers to
> prevent caching is not really an option, I'm afraid.
> 
> Thankful for any suggestions.

window.onload = function () {
   document.forms[0].reset();
}

assuming that the default values are hard-coded into the page.

-------------------------------------------------------------------
ppk, freelance web developer
Interactie, copywriting, JavaScript, integratie
http://www.quirksmode.org/ 
------------------------------------------------------------------



More information about the Javascript mailing list