自动完成关闭还是错误? [英] Autocomplete off vs false?

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

问题描述

最近我遇到了一个问题,我想在所有浏览器中禁用自动完成功能.

Recently I have come across an issue where I wanted to disable auto-complete in all browsers.

Chrome 在设置中有一项新功能,您可以在其中添加卡号.并且要求也禁用它.

Chrome has a new feature in settings where you can add a card number. And the requirement was to also disable that.

在所有浏览器中有效的是在表单级别执行此autocomplete=false.

What worked in all browsers was to do this autocomplete=false at form level.

但这不符合 w3 规则,他们强制要求 autocomplete=off|on.

But this is not compliant with w3 rules, where they enforce to have autocomplete=off|on.

谁能向我解释一下为什么 false 在所有浏览器中都有效?

Can someone please explain to me why false works in all browsers?

即使是 ie8,所有的 firefox、safari 等,但它不兼容.

even ie8, all firefox, safari etc., but it is not compliant.

推荐答案

你说得对.将自动完成属性设置为关闭"不会在较新版本的 Chrome 中禁用 Chrome 自动填充.

You are right. Setting the autocomplete attribute to "off" does not disable Chrome autofill in more recent versions of Chrome.

但是,您可以将自动完成设置为开"或关"以外的任何内容(false"、true"、nofill"),它会禁用 Chrome 自动填充.

However, you can set autocomplete to anything besides "on" or "off" ("false", "true", "nofill") and it will disable Chrome autofill.

这种行为可能是因为 autocomplete 属性需要一个on"或off"值,如果你给它其他东西,它不会做任何事情.因此,如果您给它提供除这些值以外的其他值,自动填充会崩溃/不执行任何操作.

This behavior is probably because the autocomplete attribute expects either an "on" or "off" value and doesn't do anything if you give it something else. So if you give it something other than those values, autofill falls apart/doesn't do anything.

在当前版本的 Chrome 中,我们发现将自动完成属性设置为关闭"现在确实有效.

另外,我发现只有在表单的每个 <input> 标签中设置自动完成属性时,这才有效.

Also, I have found that this only works if you set the autocomplete attribute in each <input> tag of the form.

已经对 Chromium 错误列表中的这种歧义做出了回应 这里.

There has been a response to this ambiguity in the Chromium bug listings here.

免责声明:在 Chrome 版本 47.0.2526.106(64 位)中发现这是真的

Disclaimer: This was found to be true in Chrome version 47.0.2526.106 (64-bit)

这篇关于自动完成关闭还是错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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