我有一个包含用户名和密码字段的管理表单,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/