本文介绍了通过 HTML 或 JavaScript 在网络表单上禁用自动填充?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有办法通过 HTML 或 JavaScript 禁用 Chrome 和其他浏览器中表单字段的自动填充?我不希望浏览器自动填写以前浏览器用户的表单答案.
Is there a way to disable autofill in Chrome and other browsers on form fields through HTML or JavaScript? I don't want the browser automatically filling in answers on the forms from previous users of the browser.
我知道我可以清除缓存,但我不能依靠反复清除缓存.
I know I can clear the cache, but I can't rely on repeatedly clearing the cache.
推荐答案
您可以通过将 autocomplete="off"
添加到输入中来在 HTML 的输入级别执行此操作.
You can do it at the input level in HTML by adding autocomplete="off"
to the input.
http://css-tricks.com/snippets/html/autocomplete-关闭/
您也可以通过 JS 来实现,例如:
You could also do it via JS such as:
someForm.setAttribute( "autocomplete", "off" );
someFormElm.setAttribute( "autocomplete", "off" );
这篇关于通过 HTML 或 JavaScript 在网络表单上禁用自动填充?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!