IE表单输入数据在浏览器刷新后消失

发布于 2024-09-05 20:09:23 字数 385 浏览 3 评论 0原文

我正在尝试在没有 PHP 的情况下实现粘性表单。我的设置是像 JavaScript 一样的 AJAX。后退/前进在 IE 和 FF 上都可以正常工作,但刷新仅适用于 FF,不适用于 IE。不管我使用什么缓存选项,我什至将 IE 的临时文件选项设置为从不检查更新,并且输入值在页面刷新(刷新按钮或 F5)后消失了

我读过很多帖子,人们有相反的问题,并且不希望表单数据在页面刷新后持续存在,并且从不从浏览器缓存中读取,但我这样做。

任何帮助表示赞赏,谢谢!

附注像 HTML - 刷新后保留输入值之类的帖子与我的问题完全相反

I'm trying to achieve sticky forms without PHP. My setup is AJAX like javascript. The back/forward work fine on both IE and FF, but refresh only works on FF, not IE. Doesn't matter what cache options I use, I've even set IE's temporary files option to never check for updates, and the input value is gone after page refresh(the refresh button or F5)

I've read many posts where people have the opposite problem, and do not want form data to persist across page refresh, and never read from browser cache, but I do.

Any help is appreciated, thanks!

ps. posts like HTML - input value kept after Refresh are exactly the opposite of my problems

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

素衣风尘叹 2024-09-12 20:09:23

IE/Chrome/Safari/Opera/等具有预期的行为。

我认为这是一个错误,当您单击刷新时,FF 实际上并未刷新字段。

毕竟,刷新的目的是转储您拥有的内容并从服务器重新加载。对于 Firefox 来说,将任何更改的信息/字段合并回表单是意外的行为,恕我直言,设计上很糟糕。

另请注意,Mozilla 已就这一问题争论了 10 年。它是许多重复错误报告的来源,被许多人认为是严重故障,并且坦率地说是一个完整的 PITA。我不知道有多少次我不得不向非技术人员解释为什么 Firefox 重新加载按钮没有重新加载页面。

最近我开始告诉他们 Firefox 重新加载按钮坏了,他们必须按住 Shift 键单击刷新或使用其他浏览器。值得庆幸的是我们还有选择。

--- 由于评论指出对 F5 和 Ctrl-F5 是什么感到困惑而更新 --
所有浏览器(Firefox 除外)都将 F5 视为“重新加载”。这意味着从缓存或服务器(如果缓存被禁用)重新加载页面。 Firefox 确实会重新加载,但它也会用您输入的内容重新填充所有框中...前提是这些字段仍然存在。恕我直言,这是不好的行为,因为页面可能已经更改,并且您最终处于非常无效的状态,其中一些内容已填充,而另一些则没有。

需要明确的是,缓存不包含您在页面中输入的内容;缓存仅包含服务器发送给您的内容。因此,Firefox 本身采取了这个额外的步骤来尝试合并先前输入的和未提交的数据。同样,其他浏览器都没有这样做,这也是造成很多混乱的原因。

所有浏览器(包括 Firefox)都将 Ctrl F5 视为“从服务器重新加载”。这会忽略您缓存的任何文件(图像、CSS、JavaScript 等)并从服务器中提取全新的文件。值得庆幸的是,当您按下 Ctrl-F5 时,Firefox 不会将未提交的数据合并回页面。

IE/Chrome/Safari/Opera/etc has the expected behavior.

I consider it a bug that FF doesn't actually refresh the fields when you click refresh.

After all, the purpose of the refresh is to dump what you have and reload from the server. For Firefox to then merge any changed information / fields back into the form is unexpected behavior and, IMHO, bad by design.

Also note that this one issue has been fought over at Mozilla for 10 years. It is a source of MANY duplicate bug reports, is considered by many to be a critical failure, and is quite frankly a complete PITA. I don't know how many times I've had to explain to non-techies why the Firefox reload button doesn't, well, reload the page.

Lately I've taken to just telling them that the Firefox reload button is broken and that they have to either hold down the shift key which clicking refresh or use a different browser. Thankfully we have choices.

--- Update due to a comment stating confusion as to what F5 and Ctrl-F5 are --
All browsers (except Firefox) treat F5 as "reload". Which means reload the page either from cache or from the server if cache is disabled. Firefox does do the reload, but it also repopulates any boxes with stuff you've typed in... Provided those fields still exist. IMHO, this is bad behavior as a page may have changed and you end up in a very invalid state with some things filled in and others not.

To be clear, the cache does not contain what you typed in the page; cache only contains what the server sent you. So Firefox itself takes this extra step of trying to merge previously typed in and unsubmitted data. Again, NONE of the other browsers do this and it is a source of much confusion.

All browsers (including Firefox) treat Ctrl F5 as "reload from server". This ignores any files you've cached (images, css, javascript, etc) and pulls it brand new from the server. Thankfully, Firefox does not merge unsubmitted data back into the page when you do a Ctrl-F5.

盛装女皇 2024-09-12 20:09:23

尽管我同意克里斯的观点,但这有帮助吗?

http://snipplr.com/view/799/get-url-variables/< /a>

它将允许您将内容存储在 URL 中(例如 phps GET)并使用 javascript 访问它们

Even though I agree with Chris, would this be of any help?

http://snipplr.com/view/799/get-url-variables/

It would allow you to store things in the URL (like phps GET) and access them with javascript

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文