我创建了一个使用标签框下拉的web应用程序。除了Chrome浏览器(Version 21.0.1180.89),这在所有浏览器中都很有效。
尽管输入字段和表单字段都有autocomplete="off"属性,Chrome坚持显示该字段以前条目的下拉历史,这是删除标签框列表。
我创建了一个使用标签框下拉的web应用程序。除了Chrome浏览器(Version 21.0.1180.89),这在所有浏览器中都很有效。
尽管输入字段和表单字段都有autocomplete="off"属性,Chrome坚持显示该字段以前条目的下拉历史,这是删除标签框列表。
当前回答
在form标签后添加这个:
<form>
<div class="div-form">
<input type="text">
<input type="password" >
</div>
添加到你的css文件:
.div-form{
opacity: 0;
}
其他回答
以下是我在Chrome版本51.0.2704.106上的工作方式。<input id="user_name" type="text" name="user_name" autocomplete="off" required /> And in combination with <input id="user_password" type="password" name="user_password" autocomplete="new-password" required />。我的问题是,在实现new-password之后,它仍然会在user_name字段上显示用户名的下拉列表。
我设法禁用了利用这条规则的自动合成:
不是密码,但应该隐藏的字段,例如credit 卡号,也可以有type="password"属性,但应该 包含相关的自动补全属性,例如“cc-number”或 “cc-csc”。 https://www.chromium.org/developers/design-documents/create-amazing-password-forms
<input id="haxed" type="password" autocomplete="cc-number">
然而,随之而来的是巨大的责任:)
不要试图欺骗浏览器密码管理器(或内置于 浏览器,或外部)的设计是为了简化用户体验。 插入假字段,使用错误的自动补全属性或 利用现有密码管理器的弱点 只会让用户感到沮丧。
你可以使用autocomplete="new-password"
<input type="email" name="email">
<input type="password" name="password" autocomplete="new-password">
适用于:
Chrome: 53,54,55 火狐:48、49、50
在Chrome 48+使用这个解决方案:
Put fake fields before real fields: <form autocomplete="off"> <input name="fake_email" class="visually-hidden" type="text"> <input name="fake_password" class="visually-hidden" type="password"> <input autocomplete="off" name="email" type="text"> <input autocomplete="off" name="password" type="password"> </form> Hide fake fields: .visually-hidden { margin: -1px; padding: 0; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip: rect(0, 0, 0, 0); position: absolute; } You did it!
同样,这也适用于旧版本。
我已经找到了另一个解决方案-只是用style="-webkit-text-security: disc;"遮住你的autocomplete="off"输入中的字符。 你也可以像下面这样把它添加到你的CSS规则中:
[autocomplete="off"] {
-webkit-text-security: disc;
}
主要目标是从元素中消除type="password"或其他类似的类型属性。
至少在2021年1月24日,这个解决方案是有效的……