我创建了一个使用标签框下拉的web应用程序。除了Chrome浏览器(Version 21.0.1180.89),这在所有浏览器中都很有效。
尽管输入字段和表单字段都有autocomplete="off"属性,Chrome坚持显示该字段以前条目的下拉历史,这是删除标签框列表。
我创建了一个使用标签框下拉的web应用程序。除了Chrome浏览器(Version 21.0.1180.89),这在所有浏览器中都很有效。
尽管输入字段和表单字段都有autocomplete="off"属性,Chrome坚持显示该字段以前条目的下拉历史,这是删除标签框列表。
当前回答
你可以使用下面的概念来实现AutoComplete='false' chrome以及其他浏览器。取一个虚拟输入类型,它的不透明度为0。默认chrome浏览器已经触发第一个已经隐藏。
<input style="opacity: 0; position: absolute; z-index: -1;" name="email">
<input type="search" name="email" class="form-control" autocomplete="new-email" id="email">
其他回答
当使用像jQuery UI的自动完成这样的小部件时,请确保它没有将自动完成属性添加/更改为关闭。在使用它时,我发现这是正确的,并且会破坏您为覆盖任何浏览器字段缓存所做的任何工作。确保拥有唯一的name属性,并在小部件初始化后强制使用唯一的自动完成属性。下面是一些关于如何在你的情况下工作的提示。
<?php $autocomplete = 'off_'.time(); ?>
<script>
$('#email').autocomplete({
create: function( event, ui ) {
$(this).attr('autocomplete','<? echo $autocomplete; ?>');
},
source: function (request, response) { //your code here },
focus: function( event, ui ) { //your code here },
select: function( event, ui ) { //your code here },
});
</script>
<input type="email" id="email" name="email_<? echo $autocomplete; ?>" autocomplete="<? echo $autocomplete; ?>" />
更新
现在Chrome似乎忽略了style="display: none;"或style="visibility: hidden; "属性。
你可以把它改成这样:
<input style="opacity: 0;position: absolute;">
<input type="password" style="opacity: 0;position: absolute;">
根据我的经验,Chrome只自动完成第一个<input type="password">和前一个<input>。所以我添加了:
<input style="display:none">
<input type="password" style="display:none">
到<form>的顶部,该情况得到解决。
我发现这个解决方案是最合适的:
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);
}
}
它必须在dom就绪后加载,或者在表单呈现后加载。
我发布这个答案是为了给这个问题带来一个更新的解决方案。 我目前使用的是Chrome 49,没有给出的答案。 我也在寻找一个解决方案与其他浏览器和以前的版本。
把这些代码放在表单的开头
<div style="display: none;">
<input type="text" autocomplete="new-password">
<input type="password" autocomplete="new-password">
</div>
然后,对于您的真实密码字段,使用
<input type="password" name="password" autocomplete="new-password">
如果这不再工作,或如果您遇到其他浏览器或版本的问题,请注释此答案。
批准:
Chrome浏览器:49 Firefox: 44,45 边缘:25 Internet Explorer: 11
似乎Chrome现在忽略autocomplete="off",除非它是在<form autocomplete="off">标签。