简体   繁体   中英

How can I stop Firefox from caching the contents of a textarea on localhost?

I am working on a site locally, which has a lot of <textarea> elements.

However, everytime I reload the site the content in the <textarea> is still there. This only happens when I hit reload / F5.

What can I do to stop the site from being cached, without using any in-browser functions .

I am looking for a solution within the site, so when other users in my office opens it, they won't have the same problem.

You can disable it in your html by setting the autocomplete attribute to off:

<input name="whatever" type="text" autocomplete="off">

You could also disable it for the entire form:

<form name="form1" id="form1" method="post" autocomplete="off">

https://developer.mozilla.org/en/How_to_Turn_Off_Form_Autocompletion

You might like the Webdeveloper Toolbar for Firefox. https://addons.mozilla.org/en-US/firefox/addon/web-developer/

With this toolbar you can easily disable caching, clear cookies, clear form data, disable javascript and much more. Might make your life easier :)

You can add some javascript in the head portion of your page to set the textboxes to an empty string. Then in your body onLoad event you call your javascript function which will clear it each time the browser is reloaded.

<html>
<head>
  <script type="text/javascript">
    function clear()
    {
      document.getElementById("TextBoxName").value = "";
    }
  </script>
</head>
<body onLoad="clear()">

....

</body>
</html>

Of course if the user has turned off javascript this function won't work but if it's an internal app you can control those types of settings.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM