我创建了一个使用标签框下拉的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">
其他回答
我不得不在drupal页面上用一个巨大的webform来解决这个问题。因为我不能编辑每个输入的html代码,所以我想出了下面的通用jQuery解决方案。
<script>
// Form Autocomplete FIX
function is_mobile() {
if( screen.width < 500 || navigator.userAgent.match(/Android/i) || navigator.userAgent.match(/webOS/i) || navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPod/i) ) {
return true;
}
return false;
}
jQuery( 'input[autocomplete="off"]' ).each( function() {
if( is_mobile() ) {
return;
}
jQuery( this ).attr( 'readonly', true );
} );
jQuery( 'input[autocomplete="off"]' ).focus( function() {
if( is_mobile() ) {
return;
}
jQuery( this ).removeAttr( 'readonly' );
jQuery( this ).focus();
} );
jQuery( 'input[autocomplete="off"]' ).blur( function() {
if( is_mobile() ) {
return;
}
jQuery( this ).attr( 'readonly', true );
} );
</script>
浏览器检测从这里开始。
我想有可能优化这段代码(我很想获得一些建议),但您将从中获得想法。
对任何想要解决这个问题的人来说,我终于明白了。
Chrome只服从的自动完成="off"如果页面是HTML5页面(我使用XHTML)。
我把我的页面转换成HTML5,问题就消失了(捂脸)。
Autocomplete ="off"通常有效,但并非总是如此。它取决于输入字段的名称。像“地址”,“电子邮件”,“姓名”这样的名称将被自动补全(浏览器认为他们帮助用户),而像“代码”,“pin”这样的字段将不会被自动补全(如果设置了autocomplete="off")
我的问题是-自动完成是混乱的谷歌地址助手
我通过重命名来修复它
从
<input type="text" name="address" autocomplete="off">
to
<input type="text" name="the_address" autocomplete="off">
铬71测试。
似乎Chrome现在忽略autocomplete="off",除非它是在<form autocomplete="off">标签。
2020 年 3 月
我正面临着这个问题,不幸的是,没有一个解决方案对我有效。所以我用了这个小技巧,效果很好。
<input autocomplete="off" type="password" name="password" id="password" readonly="readonly">
$('#password').on('click', function (event) {
$('#password').removeAttr('readonly');
$('#password').focus();
});
$('#password').on('blur', function (event) {
$('#password').attr('readonly', 'readonly');
});
当你点击密码输入字段,它开始显示建议,但当触发重点输入字段比它不显示建议,所以这就是我如何解决我的问题。
我希望它能帮助到一些人。