2019 年,Chrome 76,关闭自动完成功能的方法 [英] 2019, Chrome 76, approach to autocomplete off

查看:22
本文介绍了2019 年,Chrome 76,关闭自动完成功能的方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

关于这个的帖子很少.您花费数小时浏览每个答案、测试、阅读评论,发现没有解决方案.你在 2019 年做了什么,Chrome 76,有效?

解决方案

更新,2020 年 1 月: 似乎从 Chrome 79 开始,自动完成(如此处定义)不再处理 autocomplete="some-unrecognised-value" 等于 autocomplete="on",所以 autocomplete="nope" 或类似的现在可以有效地禁用两个自动完成和自动填充.

更新,2020 年 4 月:他们再次更改了它.从 Chrome 81 开始,autocomplete="some-unrecognised-value" 在禁用自动完成机制方面不再有效.然而,自动填充现在似乎比以前保守了很多 - 它仍然不遵循规范(带有 name="email"autocomplete="off" 仍会收到自动填充建议)但它不会在随机表单字段上提供虚假地址片段.因此,我现在的建议是使用 autocomplete="off".如果您想在名为 email 的字段上执行此操作,那么您可能不走运 :-(

<小时>

TL,DR:autocomplete 属性似乎没有设置可以可靠地关闭所有自动完成下拉菜单.然而,导致这种情况的情况相当复杂,值得记录,希望能澄清大量相互矛盾的建议......

当前 (76.0.3809.132) 版本的 Chrome 中存在两种不同的机制,我们将其称为自动填充和自动完成(不一定是它们的官方名称):

自动填充

自动填充功能会尝试使用浏览器设置中存储的地址信息来填写表单.它可以通过下拉列表底部的管理地址..."选项(或类似选项)来识别.此功能不尊重 autocomplete="off"autocomplete="false",这是 Chrome 开发人员的深思熟虑的决定.

自动完成功能提供了此表单字段中先前提交的值的下拉列表.此下拉菜单没有管理地址..."选项.自动完成确实尊重 autocomplete="off"autocomplete="false" 属性;任何其他值(包括无效"值,例如 autocomplete="nope")都将保持启用状态.

结论

无法通过 autocomplete 下拉菜单关闭自动完成下拉菜单;任何禁用自动填充的值都将启用自动完成,反之亦然.任何认为已经找到可行解决方案的人(通过 autocomplete 或其他一些方法,例如 CSS hacks)都应该检查它是否适用于两种机制.

不幸的是,要让 Chrome 的开发人员相信这已被破坏,可能会是一场艰苦的斗争.Autofill 的开发人员显然相信他们做出了一个经过深思熟虑的决定,即打破 autocomplete="off" 同时为 Web 开发人员提供替代方案;由于比他们意识到的更微妙的原因,这种选择被打破了.从他们的角度来看,由此产生的抗议的嚎叫来自不满开发人员懒得跳过一个小圈子并更新他们的 autocomplete="off" 属性.在所有的喧嚣中,信息并没有传递出去:箍坏了.

There are are few posts out there about this. You spend hours going through each answer, testing, reading comments, to find that there is no solution. What have you done in 2019, Chrome 76, that works?

解决方案

Update, January 2020: It appears that as of Chrome 79, Autocomplete (as defined here) no longer treats autocomplete="some-unrecognised-value" as equal to autocomplete="on", so autocomplete="nope" or similar is now effective at disabling both Autocomplete and Autofill.

Update, April 2020: They changed it again. As of Chrome 81, autocomplete="some-unrecognised-value" is no longer effective at disabling the Autocomplete mechanism. However, Autofill now seems to be a lot more conservative than it was before - it still doesn't follow the spec (a field with name="email" and autocomplete="off" will still receive Autofill suggestions) but it doesn't offer up spurious address fragments on random form fields. My recommendation right now would therefore be to use autocomplete="off". If you want to do that on a field named email, you're probably out of luck though :-(


TL,DR: There appears to be no setting for the autocomplete attribute that will reliably turn off all autocomplete dropdowns. However, the circumstances that have led to this are quite convoluted and worth documenting, to hopefully clear up the masses of conflicting advice...

There are two distinct mechanisms present in current (76.0.3809.132) versions of Chrome, which we'll refer to as Autofill and Autocomplete (not necessarily their official names):

Autofill

The Autofill feature attempts to fill in forms using the address information stored in your browser settings. It can be identified by the "Manage addresses..." option (or similar) at the bottom of the dropdown. This feature does not honour autocomplete="off" or autocomplete="false", as a deliberate decision on the part of the Chrome developers.

In a statement outlining this decision, zkoch offered this workaround:

In cases where you really want to disable autofill, our suggestion at this point is to utilize the autocomplete attribute to give valid, semantic meaning to your fields. If we encounter an autocomplete attribute that we don't recognize, we won't try and fill it.

As an example, if you have an address input field in your CRM tool that you don't want Chrome to Autofill, you can give it semantic meaning that makes sense relative to what you're asking for: e.g. autocomplete="new-user-street-address". If Chrome encounters that, it won't try and autofill the field.

This is the basis of attempted solutions such as autocomplete="nope"; the Autofill mechanism will skip any fields with autocomplete attribute values it doesn't recognise.

The code that implements this decision, for the record: https://chromium.googlesource.com/chromium/src/+/refs/tags/78.0.3903.1/components/autofill/core/browser/form_structure.cc#1218

Autocomplete

The Autocomplete feature provides a dropdown of previously-submitted values from this form field. This dropdown does not have a "Manage addresses..." option. Autocomplete does honour the autocomplete="off" or autocomplete="false" attribute; any other value (including 'invalid' ones such as autocomplete="nope") will leave it enabled.

Conclusion

Autocompletion dropdowns cannot be turned off through the autocomplete dropdown; any value that disables Autofill will leave Autocomplete enabled, and vice versa. Anyone who thinks they've found a working solution (either through autocomplete or some other method such as CSS hacks) should check that it works against both mechanisms.

Unfortunately it's probably going to be an uphill struggle to convince Chrome's developers that this is broken. The developers of Autofill apparently believe that they made a calculated decision to break autocomplete="off" while offering web developers an alternative; that alternative is broken, for more subtle reasons than they realise. From their perspective, the resulting howls of protest are coming from disgruntled developers too lazy to jump through one little hoop and update their autocomplete="off" attributes. In all the noise, the message isn't getting through: the hoop is broken.

这篇关于2019 年,Chrome 76,关闭自动完成功能的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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