我知道它在 SO 上被回答了很多次,但那是针对旧版本的 Chrome。
我有 Chrome 版本 53.0.2785.143。
我想禁用 Chrome 自动填充密码字段,
我已经尝试了旧 SO 答案中提到的所有方法,
方法一:
尝试使用虚假的用户名密码。
<input style="display:none" type="text" name="fakeusernameremembered"/>
<input style="display:none" type="password" name="fakepasswordremembered"/>
方法二:
尝试使用 autocomplete='new-password'
和 autocomplete='false'
和 autocomplete='off'
但都没有用。
最佳答案
试试这个 display:none
<input type="text" name="prevent_autofill" id="prevent_autofill" value="" style="display:none;" />
<input type="password" name="password_fake" id="password_fake" value="" style="display:none;" />
<input type="password" name="password" id="password" value="" />
你也可以使用jQuery
来解决这个问题,希望这对你有帮助,如果没有请在这里发表评论,祝你好运:)
更新:
这取决于 chrome 版本,有时这对 chrome 新版本不起作用,所以你应该尝试很多事情来防止这个问题,也试试这些代码片段,请评论发生了什么:)
方案二
$('form[autocomplete="off"] input, input[autocomplete="off"]').each(function () {
var input = this;
var name = $(input).attr('name');
var id = $(input).attr('id');
$(input).removeAttr('name');
$(input).removeAttr('id');
setTimeout(function () {
$(input).attr('name', name);
$(input).attr('id', id);
}, 1);
});
它从元素中删除“name”和“id”属性,并在 1 毫秒后将它们赋值回来。将其放入文档中准备好。
方案三
<input type="text" name="email">
<input type="password" name="password" autocomplete="new-password">
在 Chrome 53 中测试并工作
方案四
尝试使用 autocomplete="false"
而不是 autocomplete="off"
或 nofill
关于html - 如何禁用 Chrome 自动填充用户名/电子邮件密码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40200130/