在我们使用表单组件中 <input type='password'> 的时候,浏览器会询问,是否记住密码。

当选择是的时候,下次进入页面,浏览器会自动帮你填入账号和密码。而有些场景下,我们不希望浏览器帮我们自动填入,也不希望浏览器提示记住密码,这时怎么办呢?

可以采用如下方案:
1、将input的autocomplete设置为off
2、将input type设置成text,非password的type浏览器是不会提示记录的
3、给input绑定一个onfocus事件,当input获得焦点时,修改input的type为password

具体代码如下,

<input type="text" onfocus="this.type='password'" autocomplete="off"></input>

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-11-23
  • 2021-08-10
  • 2021-12-19
  • 2021-11-28
  • 2021-05-07
猜你喜欢
  • 2021-11-23
  • 2022-01-22
  • 2021-11-23
  • 2022-12-23
  • 2021-08-11
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案