强制自动完成=“关闭".在整个HTML文档上 [英] Force autocomplete="off" on whole HTML document

查看:94
本文介绍了强制自动完成=“关闭".在整个HTML文档上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以将整个HTML文档上的每个元素一次设置 autocomplete ="off" 作为标准行为?(我不是在寻找针对单个元素执行此操作的方法)

Is there a way to set autocomplete="off" as standard behaviour to every element on the whole HTML document at once? (I am not looking for a way to do this for a single element)

我正在寻找一个简单的解决方案,可能类似于HTML标头中的缓存控制的工作方式.它不一定是安全的(如果有人想以某种方式重新启用自动完成功能就可以了),我只是希望将其作为默认行为.

I am searching for an easy solution, maybe similar to how cache-control in the HTML header works. It does not have to be secure (if someone wants to somehow re-enable autocomplete that's fine), I just want it as default behaviour.

推荐答案

您可以简单地使用jquery进行此操作.请尝试以下-

You can simply do this using jquery. Try below -

$(document).ready(function(){
   $( document ).on( 'focus', ':input', function(){
     $( this ).attr( 'autocomplete', 'off' );
   });
});


OR ,您可以尝试--

$(document).ready(function(){ 
    $("input").attr("autocomplete", "off");
}); 


浏览器自动完成功能与浏览器缓存无关.缓存保存由网站发送到浏览器的实际数据,即HTML代码,CSS,Javascript和图像.自动完成功能是一种浏览器功能,可以将用户输入的内容保存到表单中.


The browser autocomplete is unrelated to the browser cache. The cache saves the actual data sent to the browser by web sites - i.e. the HTML code, CSS, Javascript and images. The autocomplete is a browser feature that saves what the user types into forms.

设置"no-cache"不会停止自动完成,只会停止浏览器将页面保存到用户的计算机.如果页面本身包含可能的敏感信息(在表单之外),请使用它,否则,用户每次访问该页面时都必须下载该页面,从而为他们和服务器使用更多的带宽.

Setting "no-cache" will not stop autocomplete, it will just stop the browser saving the page to the user's computer. If the page itself contains possibly sensitive information (outside of the form), then use it, otherwise it the user must download the page every time they visit it, using more bandwidth for them and the server.

这篇关于强制自动完成=“关闭".在整个HTML文档上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆