让 IE“忘记”使用后退按钮时在表单中输入的信息
我有一个带有表单的页面,其中许多字段都是从 URL 中传递的变量填充的。这些字段被禁用(不可编辑)并且仅供用户查看。
其余字段需要用户输入并且不能禁用(可编辑)。提交表单后,会出现确认页面。可能的情况是,用户需要提交多个这样的表单,其中各个表单的不可编辑信息是相同的,因此能够从确认页面返回到表单页面将节省大量时间。
我希望其工作方式是当用户按下后退按钮时,所有不可编辑字段都会被填充,但可编辑字段为空。这就是 Firefox 正在做的事情,但 IE8 不会“忘记”在可编辑字段中输入的内容。
要禁用缓存,以下内容将出现在我的页面开头和页面末尾。
<head>
<meta http-equiv="Pragma" content="no-cache"/>
<meta http-equiv="Cache-Control" content="no-store"/>
<head/>
我还需要做什么才能让 IE 忘记按下后退按钮时在可编辑字段中输入的内容?
如果重要的话,我的所有页面都是用 PHP 生成的。
编辑:
在我看来,这是 IE 缓存我的页面的问题,尽管我已经告诉它不要这样做。我的 meta
标签正确吗?我需要做其他事情来阻止 IE 缓存我的页面吗?
I have a page with a form where many of the fields are populated from variables passed in the URL. Those fields are disabled (NON-EDITABLE) and are only there for the user to view.
The remaining fields require user input and are NOT disabled (EDITABLE). When the form is submitted a confirmation page comes up. It may be the case that the user needs to submit several of these forms where the NON-EDITABLE information is identical from form to form, so being able to go back to the form page from the confirmation page would save a lot of time.
The way I want this to work is when a user presses the back button all the NON-EDITABLE fields are populated, but the EDITABLE fields are blank. This is what Firefox is doing, but IE8 is does not "forget" what has been entered in the EDITABLE fields.
To disable the cache the following appears at the beginning of my page AND at the end of my page.
<head>
<meta http-equiv="Pragma" content="no-cache"/>
<meta http-equiv="Cache-Control" content="no-store"/>
<head/>
What more must I do to make IE forget what was entered in the EDITABLE fields when the back button is pressed?
All of my pages are generated with PHP if that matters.
EDIT:
It appears to me that this is a problem of IE caching my page even though I have told it not to. Are my meta
tags correct? Do I need to do something else to prevent IE from caching my page?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您是否尝试过将
autocomplete='off'
属性添加到表单字段?例如这样的东西:
Have you tried adding the
autocomplete='off'
attribute to your form fields?eg something like this:
我找到了这个代码片段,它似乎可以满足我的要求。
更新:
上述解决方案在 IE 中有效,但我发现它在 Firefox 中无法正常工作。进一步探索情况,我终于在一些帮助下解决了我的问题。下面是一个更好的解决方案,将其放在
DOCTYPE
标头之上。更多详情请点击此处。I found this code snippet and it seems to do what I want.
UPDATE:
The above solution worked in IE, but I found it didn't work right in Firefox. Exploring the situation further I finally figured my issues out with some SO help. Below is a better solution, put it ABOVE your
DOCTYPE
header. More details here.为什么不直接重定向回表单,而不是让他们点击后退按钮(有一个链接显示“输入更多”,可返回表单)?
这样,当页面加载时,您可以将输入默认为空白值
示例
Why not just do a redirect back to the form instead of making them hit the back button (have a link saying "Enter More" that leads back to the form)?
This way when the page loads you can have your inputs default to a blank value
example