禁用 Chrome 自动填充 [英] Disabling Chrome Autofill

查看:38
本文介绍了禁用 Chrome 自动填充的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在多个表单上遇到了 chrome 自动填充行为的问题.

I have been running into issues with the chrome autofill behavior on several forms.

表单中的字段都有非常常见和准确的名称,例如电子邮件"、姓名"或密码",并且它们还设置了autocomplete="off".

The fields in the form all have very common and accurate names, such as "email", "name", or "password", and they also have autocomplete="off" set.

自动完成标志已成功禁用自动完成行为,即在您开始输入时会显示值的下拉列表,但并未更改 Chrome 自动填充字段的值.

The autocomplete flag has successfully disabled the autocomplete behavior, where a dropdown of values appear as you start typing, but has not changed the values that Chrome auto-populates the fields as.

这种行为是可以的,除了 chrome 错误地填充输入,例如用电子邮件地址填充电话输入.客户对此有所抱怨,因此已证实在多种情况下都会发生这种情况,而不是我在机器上本地完成的某些事情的某种结果.

This behavior would be ok except that chrome is filling the inputs incorrectly, for example filling the phone input with an email address. Customers have complained about this, so it's verified to be happening in multiple cases, and not as some some sort of result to something that I've done locally on my machine.

我能想到的唯一当前解决方案是动态生成自定义输入名称,然后在后端提取值,但这似乎是解决此问题的一种非常笨拙的方法.是否有任何可以改变自动填充行为的标签或怪癖来解决这个问题?

The only current solution I can think of is to dynamically generate custom input names and then extract the values on the backend, but this seems like a pretty hacky way around this issue. Are there any tags or quirks that change the autofill behavior that could be used to fix this?

推荐答案

2021 年 1 月: autocomplete="off" 现在按预期工作(在 Chrome 88 上测试)macOS).

Jan 2021: autocomplete="off" does work as expected now (tested on Chrome 88 macOS).

为此,请确保在表单标签中包含您的输入标签

For this to work be sure to have your input tag within a Form tag

2020 年 9 月:autocomplete="chrome-off" 禁用 Chrome 自动填充.

Sept 2020: autocomplete="chrome-off" disables Chrome autofill.

原始答案,2015 年:

对于新的 Chrome 版本,您只需在密码字段中输入 autocomplete="new-password" 即可.我检查过了,没问题.

For new Chrome versions you can just put autocomplete="new-password" in your password field and that's it. I've checked it, works fine.

在这次讨论中从 Chrome 开发人员那里得到了这个提示:https://bugs.chromium.org/p/chromium/issues/detail?id=370363#c7

Got that tip from Chrome developer in this discussion: https://bugs.chromium.org/p/chromium/issues/detail?id=370363#c7

附言请注意,Chrome 将尝试从名称、ID 和它可以在字段周围获取的任何文本内容(包括标签和任意文本节点)推断自动填充行为.如果上下文中有像 street-address 这样的自动完成标记,Chrome 将自动填充它.启发式方法可能非常令人困惑,因为它有时仅在表单中有其他字段时才触发,或者在表单中的字段太少时不会触发.另请注意,autocomplete=no" 似乎可以工作,但由于历史原因,autocomplete=off" 不会.autocomplete="no" 您是在告诉浏览器该字段应该作为名为 "no" 的字段自动完成.如果您生成唯一的随机 autocomplete 名称,您将禁用自动完成.

P.S. Note that Chrome will attempt to infer autofill behavior from name, id and any text content it can get surrounding the field including labels and arbitrary text nodes. If there is a autocomplete token like street-address in context, Chrome will autofill that as such. The heuristic can be quite confusing as it sometimes only trigger if there are additional fields in the form, or not if there are too few fields in the form. Also note that autocomplete="no" will appear to work but autocomplete="off" will not for historical reasons. autocomplete="no" is you telling the browser that this field should be auto completed as a field called "no". If you generate unique random autocomplete names you disable auto complete.

如果您的用户访问了错误的表单,他们的自动填充信息可能会损坏.让他们手动进入并修复 Chrome 中的自动填充信息可能是他们采取的必要措施.

If your users have visited bad forms their autofill information may be corrupt. Having them manually go in and fix their autofill information in Chrome may be a necessary action from them to take.

这篇关于禁用 Chrome 自动填充的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆