在Chrome浏览器中,如果我在登录时保存了网站的用户名和密码,那么在整个网站中找到Username
和Password
字段并且这些字段为空,则默认情况下会分配保存这些字段的用户名和密码。
我尝试使用autocomplete ='off',并将这些字段名称重命名为txtUN
,而不是txtUserName
和txtPass
,而不是txtPassword
,但它不起作用。
那么如何防止自动填写用户名和密码字段?有人可以帮忙吗?
由于
答案 0 :(得分:2)
在本文中查看迈克纳尔逊的答案
更新了解决方案
Chrome现在忽略了。因此,我原来的解决方法(我已删除)现在风靡一时。
只需创建几个字段并使用" display:none"隐藏它们。例如:
<!-- fake fields are a workaround for chrome autofill getting the wrong fields -->
<input style="display:none" type="text" name="fakeusernameremembered"/>
<input style="display:none" type="password" name="fakepasswordremembered"/>
答案 1 :(得分:0)
尝试退出并重新启动您的Google / gmail帐户以获取自动填充选项,否则请在偏好设置中检查您的隐私设置。
答案 2 :(得分:-1)
$(document).ready(function(){ 调试器
$('input[autocomplete="off"]').each(function () {
debugger
var input = this;
var name = $(input).attr('name');
var id = $(input).attr('id');
$(input).removeAttr('name');
$(input).removeAttr('id');
setTimeout(function () {
debugger
$(input).attr('name', name);
$(input).attr('id', id);
}, 1);
});
});
在此之前,为您想要的每个字段添加autocomplete =“off”。