以下是代码:
<form method="post" action="default.aspx" id="form1" autocomplete="off">
<div class="loginContnet">
<input " name="SC_Login1$txtUserCode" type="text" id="SC_Login1_txtUserCode" class="txtUserCode" autocomplete="off">
<input name="SC_Login1$txtPassword" type="password" id="SC_Login1_txtPassword" class="txtPassword" autocomplete="off">
<input type="submit" name="SC_Login1$btnOK" value="OK" id="SC_Login1_btnOK" class="btnOK">
</div>
</form>
为什么除了Mozilla之外的所有浏览器都会询问保存密码,以及如何防止这种情况发生?
事实上,浏览器不会为密码保存/恢复提供autocomplete="off"属性。
我最近确实遇到了同样的问题,并用一个漂亮漂亮的破解方法解决了它,正如你在下面看到的那样。诀窍在于有两个对应于登录名和密码的字段显示:none;,因此浏览器认为这是实际的登录名和密码字段!哈哈,愚蠢的浏览器!
<form>
<input type="text" id="email" name="email" size="40" autocomplete="off" />
<input type="text" style="display: none;" name="loginForAutoCompleteDisable" />
<input type="password" style="display: none;" name="passwordForAutoCompleteDisable" />
<input type="password" id="password" name="password" autocomplete="off" />
</form>
希望这能有所帮助!
autocomplete=off
仅告诉浏览器不要显示基于您的浏览历史记录的建议。
它与保存密码
据我所知,autocomplete-attribute
用于显示基于先前输入值的建议。它与"保存密码"问题无关。我不认为你可以通过html禁用"保存密码"问题,因为它取决于每个客户端。
使用此属性的唯一问题是它不是标准属性(它适用于IE和Mozilla浏览器)
回答这个问题
<form method="post" action="default.aspx" id="form1" autocomplete="off">
<div class="loginContnet">
<input name="SC_Login1$txtUserCode" type="text" id="SC_Login1_txtUserCode" class="txtUserCode" autocomplete="off">
<input name="SC_Login1$txtPassword" type="password" id="SC_Login1_txtPassword" class="txtPassword" autocomplete="off">
<input type="submit" name="SC_Login1$btnOK" value="OK" id="SC_Login1_btnOK" class="btnOK">
</div>
</form>