我创建了一个使用标签框下拉的web应用程序。除了Chrome浏览器(Version 21.0.1180.89),这在所有浏览器中都很有效。

尽管输入字段和表单字段都有autocomplete="off"属性,Chrome坚持显示该字段以前条目的下拉历史,这是删除标签框列表。


当前回答

始终有效的解决方案

我用随机字符的使用解决了谷歌Chrome无休止的战斗。当你总是用随机字符串渲染自动补全时,它永远不会记住任何东西。

<input name="name" type="text" autocomplete="rutjfkde">

希望对其他人有所帮助。

2022年更新:

Chrome做了这个改进:autocomplete="new-password"这将解决它,但我不确定,如果Chrome在一段时间后再次更改为不同的功能。

其他回答

在chrome v. 34之后,在<form>标记处设置autocomplete="off"不起作用

我做这些改变是为了避免这种恼人的行为:

删除密码输入的名称和id 在输入中放入一个类(例如:passwordInput)

(到目前为止,Chrome不会把保存的密码输入,但形式现在是破碎的)

最后,为了让表单工作,当用户点击提交按钮时,或者当你想触发表单提交时,运行以下代码:

var sI = $(".passwordInput")[0];
$(sI).attr("id", "password");
$(sI).attr("name", "password");

在我的情况下,我曾经在密码输入中有id="password" name="password",所以我在触发提交之前把它们放回去。

看起来这是固定的!参见https://codereview.chromium.org/1473733008

[2021年适用于Chrome(v88, 89, 90), Firefox, Brave, Safari] 旧的答案已经写在这里,将适用于试验和错误,但大多数 他们没有链接到任何官方文件或什么Chrome不得不说这一点 的事。

问题中提到的问题是因为Chrome的自动填充功能,这里是Chrome在这个bug链接中的立场- https://bugs.chromium.org/p/chromium/issues/detail?id=468153#c164

简单地说,有两种情况-

[CASE 1]: Your input type is something other than password. In this case, the solution is simple, and has three steps. Add name attribute to input name should not start with a value like email or username, otherwise Chrome still ends up showing the dropdown. For example, name="emailToDelete" shows the dropdown, but name="to-delete-email" doesn't. Same applies for autocomplete attribute. Add autocomplete attribute, and add a value which is meaningful for you, like new-field-name It will look like this, and you won't see the autofill for this input again for the rest of your life - <input type="text/number/something-other-than-password" name="x-field-1" autocomplete="new-field-1" /> [CASE 2]: input type is password Well, in this case, irrespective of your trials, Chrome will show you the dropdown to manage passwords / use an already existing password. Firefox will also do something similar, and same will be the case with all other major browsers. [1] In this case, if you really want to stop the user from seeing the dropdown to manage passwords / see a securely generated password, you will have to play around with JS to switch input type, as mentioned in the other answers of this question.

[1]关于关闭自动补全的详细MDN文档- https://developer.mozilla.org/en-US/docs/Web/Security/Securing_your_site/Turning_off_form_autocompletion

在form标签后添加这个:

<form>
<div class="div-form">
<input type="text">
<input type="password" >
</div>

添加到你的css文件:

.div-form{
opacity: 0;
}

当使用像jQuery UI的自动完成这样的小部件时,请确保它没有将自动完成属性添加/更改为关闭。在使用它时,我发现这是正确的,并且会破坏您为覆盖任何浏览器字段缓存所做的任何工作。确保拥有唯一的name属性,并在小部件初始化后强制使用唯一的自动完成属性。下面是一些关于如何在你的情况下工作的提示。

<?php $autocomplete = 'off_'.time(); ?>
<script>
   $('#email').autocomplete({
      create: function( event, ui ) {
         $(this).attr('autocomplete','<? echo $autocomplete; ?>');
      },
      source: function (request, response) { //your code here },
      focus: function( event, ui ) { //your code here },
      select: function( event, ui ) { //your code here },
   });
</script>
<input type="email" id="email" name="email_<? echo $autocomplete; ?>" autocomplete="<? echo $autocomplete; ?>" />