我创建了一个使用标签框下拉的web应用程序。除了Chrome浏览器(Version 21.0.1180.89),这在所有浏览器中都很有效。
尽管输入字段和表单字段都有autocomplete="off"属性,Chrome坚持显示该字段以前条目的下拉历史,这是删除标签框列表。
我创建了一个使用标签框下拉的web应用程序。除了Chrome浏览器(Version 21.0.1180.89),这在所有浏览器中都很有效。
尽管输入字段和表单字段都有autocomplete="off"属性,Chrome坚持显示该字段以前条目的下拉历史,这是删除标签框列表。
当前回答
自动完成=“关闭”不再工作。
尝试使用一个随机字符串来代替"Off",例如Autocomplete="NoAutocomplete"
我希望这能有所帮助。
其他回答
在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",所以我在触发提交之前把它们放回去。
在Chrome和Firefox上工作和测试成功的唯一解决方案是用一个具有autocomplete="off"的表单来包装输入,如下所示:
<form autocomplete="off">
<input id="xyz" />
</form>
除了给它一个自动补全的假字段外,所有的解决方案都不起作用。我做了一个React组件来解决这个问题。
import React from 'react'
// Google Chrome stubbornly refuses to respect the autocomplete="off" HTML attribute so
// we have to give it a "fake" field for it to autocomplete that never gets "used".
const DontBeEvil = () => (
<div style={{ display: 'none' }}>
<input type="text" name="username" />
<input type="password" name="password" />
</div>
)
export default DontBeEvil
Chrome一直在改变它在每个版本上处理自动完成的方式,我提出的方式是,使字段只读和onclick/focus使它非只读。试试这个jQuery片段。
jQuery(document).ready(function($){
//======fix for autocomplete
$('input, :input').attr('readonly',true);//readonly all inputs on page load, prevent autofilling on pageload
$('input, :input').on( 'click focus', function(){ //on input click
$('input, :input').attr('readonly',true);//make other fields readonly
$( this ).attr('readonly',false);//but make this field Not readonly
});
//======./fix for autocomplete
});
我已经找到了另一个解决方案-只是用style="-webkit-text-security: disc;"遮住你的autocomplete="off"输入中的字符。 你也可以像下面这样把它添加到你的CSS规则中:
[autocomplete="off"] {
-webkit-text-security: disc;
}
主要目标是从元素中消除type="password"或其他类似的类型属性。
至少在2021年1月24日,这个解决方案是有效的……