简体   繁体   English

如何阻止Firefox在localhost上缓存textarea的内容?

[英]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. 我在本地工作,有很多<textarea>元素。

However, everytime I reload the site the content in the <textarea> is still there. 但是,每次我重新加载网站时, <textarea>内容仍然存在。 This only happens when I hit reload / F5. 这只有在我点击重装/ 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: 您可以通过将autocomplete属性设置为off来在html中禁用它:

<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 https://developer.mozilla.org/en/How_to_Turn_Off_Form_Autocompletion

You might like the Webdeveloper Toolbar for Firefox. 您可能喜欢Firefox的Webdeveloper工具栏。 https://addons.mozilla.org/en-US/firefox/addon/web-developer/ 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. 使用此工具栏,您可以轻松禁用缓存,清除cookie,清除表单数据,禁用JavaScript等等。 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. 您可以在页面的头部添加一些javascript,将文本框设置为空字符串。 Then in your body onLoad event you call your javascript function which will clear it each time the browser is reloaded. 然后在你的身体onLoad事件中你调用你的javascript函数,它将在每次重新加载浏览器时清除它。

<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. 当然,如果用户已关闭javascript,此功能将无法使用,但如果它是内部应用程序,您可以控制这些类型的设置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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