通过 HTML 在 IE 中禁用自动完成/预填充?

发布于 2024-09-07 12:45:09 字数 347 浏览 2 评论 0原文

演示链接: http://elevation-inc.com/dev/test/ieform/

在IE 6/7/8 - 如果您在简单的输入字段中输入术语,提交表单,然后单击后退按钮 - 输入字段将保留之前提交的术语。如果您随后刷新页面,该值也会保留。

如何通过 HTML 禁用此预填充?我们不希望页面加载/domready 时的输入框中没有任何值。

我们已经在表单和输入元素上尝试了 autocomplete='off',但预填充仍然存在。

提前致谢。

Demo link:
http://elevation-inc.com/dev/test/ieform/

In IE 6/7/8 - if you enter a term into a simple input field, submit the form and then hit the back button - the input field retains the previously submitted term. If you then refresh the page, the value is also retained.

How, via HTML, can this pre-population be disabled? We want no value to be in the input box on page load/domready.

We've already tried autocomplete='off' on both the form and input element, but the pre-population is still persisting.

Thanks in advance.

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

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

发布评论

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

评论(3

白芷 2024-09-14 12:45:42

好吧,我猜这是浏览器的行为,你无法通过 html 绕过。但是,您可以在 javascript 中执行此操作:

<script>
window.onload = function() { document.forms.f.q.value = ""; };
</script>

或者如果您不想等待图像加载(因为 window.onload 会等待),
您可以使用文档就绪事件,如此处所述。 (它需要更多调整才能在所有浏览器上运行)

Well I guess it's a browser behaviour you can't bypass by html. You can do it in javascript however:

<script>
window.onload = function() { document.forms.f.q.value = ""; };
</script>

or if you don't want to wait for images to load (because window.onload will wait for that),
you can use the document ready event, as described here. (it needs more tweaking to make it work across all browsers)

不必你懂 2024-09-14 12:45:34

这就是 IE 的工作方式,但您可以使用 JavaScript 更改该值

<body onload="document.getElementById('q').value = '';">
<form action="http://www.google.com/search" name="f" autocomplete="off">
    <input type="text" name="q" autocomplete="off" id="q"><input type="submit">
</form>

This is how IE works, but you can change the value with JavaScript

<body onload="document.getElementById('q').value = '';">
<form action="http://www.google.com/search" name="f" autocomplete="off">
    <input type="text" name="q" autocomplete="off" id="q"><input type="submit">
</form>
执妄 2024-09-14 12:45:28

对我来说效果很好(您的表单也一样)。确保在测试之间重新加载页面(CTRL + F5 进行完全刷新)。

<input type="text" name="userid" autocomplete="off" /> works fine for me (the same goes with your form). Make sure you reload the page in between testing (CTRL + F5 for full refresh).

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