清除input密码框缓存问题---'autocomplete="off"'在Chrome中不起作用

本文介绍了两种防止浏览器自动填充密码的方法。方法一是在输入框中使用autocomplete=off属性;方法二是通过设置readonly属性并在聚焦时移除它来实现。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

若是将用户信息保存在cookie中,当我们记住密码时,密码框会自动填入被保存的用户信息,若密码框不想被自动填入数据的话,有两种方法。

方法一:

 在<input type="password"  id="confirmpassword" placeholder="确认密码" autocomplete="off">中先用autocomplete="off",该参数是取消密码框的自动填入。但是有可能这个参数无效。若是无效,则使用另外一种方法。

方法二:

<input type="password" name="operatePwd" id="operatePwd" readonly onfocus="this.removeAttribute('readonly');">使用该参数也会使密码框自动填入失效。

经过验证,第二种方法更有效。

参考网址:https://blog.youkuaiyun.com/xw505501936/article/details/52129579

个人原创,转载请注明出处。

<!DOCTYPE html> <html> <head> <title>{title}</title> <meta http-equiv="Content-Type" content="text/html; charset={charset}" /> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /> <link rel="stylesheet" type="text/css" href="{static_server}/static/templates/2016_01/index.css?20160506"/> <link rel="shortcut icon" href="{static_server}/static/images/tongda.ico" /> {javascript} </head> <body onload="javascript:document.form1.{focus_filed}.focus();" scroll="auto"> {update_tips} <img src="/static/templates/2016_01/tdxk.png" class="tdxk" /> <form class="login_form" name="form1" method="post" action="logincheck.php" {autocomplete} onsubmit="{form_submit}"> <div id="center" class="center"> <img src="/static/templates/2016_01/logo.png" class="logo"> <div class="input-wrap name"> <label for="name">用户名:</label> <input type="text" id="name" name="UNAME" maxlength="20" onmouseover="this.focus()" onfocus="this.select()" value="{username_cookie}" placeholder="请输入用户名"/> </div> <div class="input-wrap password"> <label for="password">密 码:</label> <input type="password" id="password" name="PASSWORD" maxlength="200" onmouseover="this.focus()" onfocus="this.select()" value="" placeholder="请输入密码"/> </div> <!-- <div > --> <input type="hidden" name="encode_type" value="1"> <button type="submit" id="submit" class="login_btn" title="登录">登录</button> <!-- </div> --> <!--<div class="logo"><img src="{static_server}/static/templates/2015_02/logo.png" /></div>--> <!--<div class="clear"></div>--> </div> <div style="margin-top: 30px;text-align:center;font-size: 30px;line-height: 40px;color:red;"><strong>非密信息系统,禁止存储,处理和传输涉密信息!</strong></div> <div class="msg" style="width: 350px;margin: 0 auto;"> <div>{tips}</div> <div>{usb_key_option}</div> <div>{miibeian}</div> <div>{antivirus_script}</div> </div> <!--设置公司特色注释 <div align="center" class="msg"> <div><span style='color:red;margin-right:10px;'>xxxxxx</span><a href='http://www.tongda2000.com/' target='_black'>通达官网</a></div> </div> 设置公司特色注释 结束--> <div style="width: 350px;margin: 0 auto;">{usbkey_object}</div> </form> </body> </html> 帮我分析一下
最新发布
07-11
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值