浏览器自动填充用户名与密码问题:
根据网上找到的各种方法总结说是在前面加一个隐藏的输入框,例如:
1.设置autocomplete=”off”能去除chrom自动填充
2.添加隐藏输入框,设置autocomplete=”off”,所有浏览器不再出现自动填充问题
<input type="text" style="display:none;">
<input type="password" style="display:none;">
<input type="password" name="xx" id='xx' value="" autocomplete="off">
3.为隐藏的输框设置相同的id属性,而提交表单只用到name,因此设置相同的id属性即可保证所有浏览器不再出现自动填充问题
<input type="text" style="display:none;">
<input type="password" id="xx" style="display:none;">
<input type="password" name="xx" id='xx' value="" autocomplete="off">
经过测试发现以上方法并没有起作用,经过各种查找与测试发现需要autocomplete设置为“new-password”
<input type="text" style="display:none;">
<input type="password" style="display:none;">
<input type="password" name="xx" id='xx' value="" autocomplete="new-password">
经测试发现只要密码符合了不自动填充,用户名自动填充也不会发生,即使不添加用户名隐藏的输入框,也不影响;
结论:
若需要实现用户名与密码的不自动填充问题,只要密码不自动填充用户也不会发生
谷歌浏览器可以直接设置密码输入框即可实现:
<input type="password" name="xx" id='xx' value="" autocomplete="new-password">
若需要谷歌与火狐均实现需要以下即可:
<input type="password" style="display:none;"><!--设置火狐-->
<input type="password" name="xx" id='xx' value="" autocomplete="new-password">