Html 禁用 Google Chrome 自动完成/自动填充/建议
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/43783924/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Disable Google Chrome Autocomplete / Autofill / Suggestion
提问by Satrio Wibowo
I want to disable google chrome autocomplete / autofill / use password suggestion
Something similar with autocomplete="off" (this one is not working).
我想禁用谷歌浏览器自动完成/自动填充/使用密码建议
与 autocomplete="off" 类似的东西(这个不起作用)。
The code is as following
代码如下
loginpage.php
登录页面.php
<form class="form-method" method="post">
<span class="form-fill">
<text>Username</text>
<input placeholder="Username" required/>
<text>Password</text>
<input type="password" placeholder="Password" required/>
<button type="submit"></button>
</span>
</form>
anotherform.php
另一个表单.php
<form method="REQUEST" class="vp-method">
<input type="password" maxlength="4" autocomplete="JUST STOP!"/>
<button type="submit" placeholder="DVN Number">Validate</button>
</form>
How to disable this google chrome autocomplete / suggestion / autofill WITHOUT using javascript?
如何在不使用 javascript 的情况下禁用此 google chrome 自动完成/建议/自动填充?
Note : I'm aware of duplicating question. And none of those suggestion is working (as I'm typing right now).
注意:我知道重复问题。这些建议都不起作用(因为我现在正在打字)。
Thank you :)
谢谢 :)
回答by Ethilium
Chrome no longer supports autocomplete="off"
. Use autocomplete="new-password"
instead.
Mozilla link
Chrome 不再支持autocomplete="off"
. 使用autocomplete="new-password"
来代替。
Mozilla 链接
From the documentation:
从文档:
For this reason, many modern browsers do not support
autocomplete="off"
for login fields:If a site sets
autocomplete="off"
for username and password input fields, then the browser will still offer to remember this login, and if the user agrees, the browser will autofill those fields the next time the user visits the page. This is the behavior in Firefox (since version 38), Google Chrome (since 34), and Internet Explorer (since version 11).If an author would like to prevent the autofilling of password fields in user management pages where a user can specify a new password for someone other than themself,
autocomplete="new-password"
should be specified, though support for this has not been implemented in all browsers yet.
出于这个原因,许多现代浏览器不支持
autocomplete="off"
登录字段:如果站点设置
autocomplete="off"
了用户名和密码输入字段,那么浏览器仍会提供记住此登录信息,如果用户同意,浏览器将在用户下次访问该页面时自动填充这些字段。这是 Firefox(自版本 38)、Google Chrome(自 34)和 Internet Explorer(自版本 11)中的行为。如果作者想阻止在用户管理页面中自动填充密码字段,用户可以在其中为自己以外的人指定新密码,
autocomplete="new-password"
则应指定,尽管尚未在所有浏览器中实现对此的支持。
Another solution is using autocomplete="false"
. Here are a few links to other SO questions that may help:
另一种解决方案是使用autocomplete="false"
. 以下是一些可能有帮助的其他 SO 问题的链接:
SO - Disabling Chrome Autofill
SO - Chrome Browser Ignoring AutoComplete=Off
SO - Chrome 浏览器忽略 AutoComplete=Off
回答by Dan
I tried to confuse the browser so that it wouldn't know which input field to fill, and this seems to be cross platform - can't test it on explorer thouth...
我试图混淆浏览器,使其不知道要填充哪个输入字段,这似乎是跨平台的 - 无法在资源管理器上进行测试...
Try this, or something along these lines:
试试这个,或者类似的东西:
<input type="password" class="bigText login" name="hiddenFieldToStopBrowserAutofill" style = "height : 0px; width : 0px; border : 0px"/>
From what I saw, it only works if you specify the same class as another of the fields in the form ( in this case i have "bigText login" for both password and email address ) and then make it invisible in the way I described above. If you try to use "display = none" instead, it won't work.
从我看到的情况来看,它只有在您指定与表单中的另一个字段相同的类时才有效(在这种情况下,我对密码和电子邮件地址都有“bigText login”),然后以我上面描述的方式使其不可见. 如果您尝试改用“display = none”,它将不起作用。
I also tried some variations of value = "", value = " " and so on to stop the browser replacing the string with what it wants to force on the page, but it didn't work... Saves you time trying that if you were hoping for a cleaner opton
我还尝试了 value = ""、value = " " 等的一些变体来阻止浏览器将字符串替换为它想要强制在页面上使用的内容,但它没有用...节省您尝试的时间,如果你希望有一个更干净的选择