浏览器保存账号密码乱填充现象

先搞懂原理

原理很简单,浏览器记住密码后只要识别到一个type为text后又紧接着一个password

时默认填充之前浏览器记住的账号密码。

解决方案

1.把input type=”password” 改成 input type=”text” 并在后面加上 οnfοcus=”this.type=’password'”,

2.在文档加载完成后将密码输入框设置为空:
window.load = function(){
document.getElementById('密码域ID').value='';
};

3.在用户名和密码之间加上一个隐藏的文本框:
<input type="text" name="name">
<input type="text" class="hidden">
<input type="password" name="pwd">

4.使用HTML5的属性:
<pre name="code" class="html"><input type="text" name="name" autocomplete="off">
<input type="password" name="pass" autocomplete="off">

发布了25 篇原创文章 · 获赞 10 · 访问量 3万+

猜你喜欢

转载自blog.csdn.net/xj932956499/article/details/81745850