html - 如何避免在 Chrome 的表单中自动填充用户名/密码?

标签 html forms google-chrome

我有一个包含用户名和密码字段的管理表单,Chrome 正在填写该表单,因为它记住了用户名和密码。 我想防止这些字段被自动填充。 我进行了大量搜索,并且已经尝试过自动完成标签(在输入和表单中)、displany:none 在样式标签中以及对 dissabled 自动完成的 javascript 调用……但这些都没有用。

你能帮我一下吗?

谢谢!

最佳答案

要点链接 https://gist.github.com/runspired/b9fdf1fa74fc9fb4554418dea35718fe

<!--
  <form autocomplete="off"> will turn off autocomplete for the form in most browsers
  except for username/email/password fields
  -->
<form autocomplete="off">

  <!--  fake fields are a workaround for chrome/opera autofill getting the wrong fields -->
  <input id="username" style="display:none" type="text" name="fakeusernameremembered">
  <input id="password" style="display:none" type="password" name="fakepasswordremembered">

  <!--
    <input autocomplete="nope"> turns off autocomplete on many other browsers that don't respect
    the form's "off", but not for "password" inputs.
  -->
  <input id="real-username" type="text" autocomplete="nope">

  <!--
    <input type="password" autocomplete="new-password" will turn it off for passwords everywhere
    -->
  <input id="real-password" type="password" autocomplete="new-password">

</form>

关于html - 如何避免在 Chrome 的表单中自动填充用户名/密码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25569548/

相关文章:

javascript - 为什么这会返回一个空数组?

javascript - 从 javascript 检索表单提交的状态

javascript - 如何计算 Javascript 与 HTML 周表的周差?

javascript - 在一页上使用 id ="submit"两次

css - 固定大小的图片在加载时在 chrome 中折叠

javascript - 表格不发送电子邮件?

html - CSS id 在 div 中不起作用

html - 关于 float 和清除

javascript - POST 字段被 Chrome chop

javascript - 在单个 chrome 扩展上编写大量 JS 注入(inject)代码