为了用户体验,我想在所有浏览器中禁用 google chrome 的持久自动完成功能(我的 Chrome 版本是 76).我尝试了很多解决方案,包括:
I want to disable google chrome's persistent autocomplete in all browser for user experience (my Chrome version is 76). I have tried many solution including :
1).答案来自Chrome 忽略自动完成=off"
2).所有的答案来自自动完成 ='off' 输入类型为密码时不起作用,并在其上方输入字段以启用自动完成
其中包括
1).Autocomplete="off", autocomplete="somerandomstring"
1). Autocomplete="off", autocomplete="somerandomstring"
2).在其上方创建另一个具有隐藏样式的假输入
2). create another fake input above it with hidden style
3).用不可见的 div 包裹它
3). wrap it with invisible div
似乎这两个链接的答案都是谷歌浏览器过时版本的解决方案,几乎可能早于 76 浏览器版本.
It seems that the answers from both links are the solution for the outdated version of google chrome almost likely older than 76 chrome version.
<input name="number" type="text" class="form-control search" placeholder="No. Invoice" >
//this input is getting filled with persistent google chrome autocomplete
预期输出:未填充自动完成
Expected Output : not filled with autocomplete
实际输出:填充
提前谢谢你!
我刚遇到同样的问题,原来的答案似乎都不起作用.
I just came across this same issue and none of the original answers seem to work.
当我使用占位符文本时,我想出了一个解决方案,如果值为空白,则添加占位符文本作为值,以及更改颜色,然后使用 onfocus 事件删除值,如果它等于占位符并移除颜色.
As i use the placeholder text, I came up with a solution of adding the placeholder text as the value if the value is blank, as well as changing the color and then use the onfocus event to remove the value if it's equal to the placeholder and remove the color.
这是一个例子:
<input type="text" class="form-control" id="search" placeholder="Search Users" value='Search Users' style="color: #6c757d;" onfocus="if (this.value == this.placeholder) {this.value=''; this.style.color=null;}">
你仍然需要注意的事情:
The things that you would still have to look out for:
我发现还有另一种解决方案:
There is one other solution that i found worked:
向空输入添加一个值,然后使用超时将其删除,这应该在自动完成运行后发生.
Add a value to empty input and then remove it using a timeout, this should happen after the autocomplete has run.
html:
<input type="text" class="form-control NoAutoComplete" id="search" placeholder="Search Users" value='Search Users'>
CSS:
.NoAutoComplete {
color: #6c757d;
}
JS:
setTimeout(function () {
$(".NoAutoComplete").val("");
$(".NoAutoComplete").removeClass( "NoAutoComplete" );
}, 1000);
我对此并没有做太多研究,但您应该能够为所有不需要值的输入添加一个类,然后同时删除所有值和类.
i haven't done to much looking in to this, but you should be able to add a class to all inputs that need not have a value and then delete all values and class at the same time.
这篇关于Google Chrome 版本 76.0.3809.100(官方版本)(64 位)自动完成行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!