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

去除表单主动填入明码

  • 在表单头设置一个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办法有效

评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理