关于html:清除form缓存阻止自动填充密码

2次阅读

共计 575 个字符,预计需要花费 2 分钟才能阅读完成。

去除表单主动填入明码

  • 在表单头设置一个 type 类型为 password 的 input,超出暗藏,主动填充明码是依据 type 判断,这时主动填充就会填充到这个超出暗藏的 input 框内
    <input type="password" style="position:fixed;bottom:-9999px"/>
  • 应用 h5 属性 autocomplete=“new-password”,失常来讲该属性作用为阻止主动填充,值赋为“off”会阻止主动填充才对,但这里赋为“new-password”才有用
  <input type="password" autocomplete="new-password" />
  • 在文档加载实现后讲明码输入框设置为空
  window.laod = fcuntion() {document.getElementById('#password').value = ''
  }
  • 在用户名和明码之间加上一个暗藏的文本框
  <input type="text" />
  <input type="hidden" />
  <input type="password" />
  • 把 input 的 type="password" 改为type="text",并把 focus 事件设为onfocus="this.type=password"

留神:通过测试,目前来看在 chrome,vue2.x 中 1、2 办法无效,3,4,5 办法有效

正文完
 0