Google Chrome 版本 76.0.3809.100(官方版本)(64 位)自动完成行为

2023-09-05前端开发问题
266

本文介绍了Google Chrome 版本 76.0.3809.100(官方版本)(64 位)自动完成行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

为了用户体验,我想在所有浏览器中禁用 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 位)自动完成行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

js删除数组中指定元素的5种方法
在JavaScript中,我们有多种方法可以删除数组中的指定元素。以下给出了5种常见的方法并提供了相应的代码示例: 1.使用splice()方法: let array = [0, 1, 2, 3, 4, 5];let index = array.indexOf(2);if (index -1) { array.splice(index, 1);}// array = [0,...
2024-11-22 前端开发问题
182

JavaScript小数运算出现多位的解决办法
在开发JS过程中,会经常遇到两个小数相运算的情况,但是运算结果却与预期不同,调试一下发现计算结果竟然有那么长一串尾巴。如下图所示: 产生原因: JavaScript对小数运算会先转成二进制,运算完毕再转回十进制,过程中会有丢失,不过不是所有的小数间运算会...
2024-10-18 前端开发问题
301

JavaScript(js)文件字符串中丢失"\"斜线的解决方法
问题描述: 在javascript中引用js代码,然后导致反斜杠丢失,发现字符串中的所有\信息丢失。比如在js中引用input type=text onkeyup=value=value.replace(/[^\d]/g,) ,结果导致正则表达式中的\丢失。 问题原因: 该字符串含有\,javascript对字符串进行了转...
2024-10-17 前端开发问题
437

layui中table列表 增加属性 edit="date",不生效怎么办?
如果你想在 layui 的 table 列表中增加 edit=date 属性但不生效,可能是以下问题导致的: 1. 缺少日期组件的初始化 如果想在表格中使用日期组件,需要在页面中引入 layui 的日期组件,并初始化: script type="text/javascript" src="/layui/layui.js"/scrip...
2024-06-11 前端开发问题
455

Rails/Javascript:如何将 rails 变量注入(非常)简单的 javascript
Rails/Javascript: How to inject rails variables into (very) simple javascript(Rails/Javascript:如何将 rails 变量注入(非常)简单的 javascript)...
2024-04-20 前端开发问题
5

CoffeeScript 总是以匿名函数返回
CoffeeScript always returns in anonymous function(CoffeeScript 总是以匿名函数返回)...
2024-04-20 前端开发问题
13