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

本文翻译自: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? 你的意见怎么样?

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值