Chrome会忽略autocomplete =“off”[重复]

赫连子石
2023-12-01

本文翻译自:Chrome ignores autocomplete=“off” [duplicate]

This question already has an answer here: 这个问题在这里已有答案:

I've created a web application which uses a tagbox drop down. 我创建了一个使用标记框下拉列表的Web应用程序。 This works great in all browsers except Chrome browser (Version 21.0.1180.89). 这适用于除Chrome浏览器(版本21.0.1180.89)以外的所有浏览器。

Despite both the input fields AND the form field having the autocomplete="off" attribute, Chrome insists on showing a drop down history of previous entries for the field, which is obliterating the tagbox list. 尽管input字段和form字段都具有autocomplete="off"属性,但Chrome仍然会显示该字段的先前条目的下拉历史记录,这会删除标记框列表。


#1楼

参考:https://stackoom.com/question/pv9m/Chrome会忽略autocomplete-off-重复


#2楼

to anyone looking for a solution to this, I finally figure it out. 对于那些寻找解决方案的人来说,我终于明白了。

Chrome only obey's the autocomplete="off" if the page is a HTML5 page (I was using XHTML). 如果页面是HTML5页面(我使用的是XHTML),Chrome只会遵守autocomplete =“off”。

I converted my page to HTML5 and the problem went away (facepalm). 我将页面转换为HTML5,问题消失了(facepalm)。


#3楼

Chrome现在似乎忽略了autocomplete="off"除非它位于<form autocomplete="off">标记上。


#4楼

i found this solution to be the most appropriate: 我发现这个解决方案是最合适的:

function clearChromeAutocomplete()
{
// not possible, let's try: 
if (navigator.userAgent.toLowerCase().indexOf('chrome') >= 0) 
{
document.getElementById('adminForm').setAttribute('autocomplete', 'off'); 
setTimeout(function () {
        document.getElementById('adminForm').setAttribute('autocomplete', 'on'); 
}, 1500);
}
}

It must be loaded after dom ready, or after the form renders. 它必须在dom准备好后或表单渲染后加载。


#5楼

UPDATE UPDATE

It seems now Chrome ignores the style="display: none;" 现在看来Chrome忽略了style="display: none;" or style="visibility: hidden; attributes. style="visibility: hidden; attributes。

You can change it to something like: 您可以将其更改为:

<input style="opacity: 0;position: absolute;">
<input type="password" style="opacity: 0;position: absolute;">

In my experience, Chrome only autocompletes the first <input type="password"> and the previous <input> . 根据我的经验,Chrome只会自动填充第一个<input type="password">和前一个<input> So I've added: 所以我添加了:

<input style="display:none">
<input type="password" style="display:none">

To the top of the <form> and the case was resolved. <form>的顶部,案件得到了解决。


#6楼

Chrome version 34 now ignores the autocomplete=off , see this . Chrome版本34现在忽略了autocomplete=off请参阅此内容

Lots of discussion on whether this is a good thing or a bad thing? 关于这是好事还是坏事的讨论很多 Whats your views? 你的意见怎么样?

 类似资料: