【发布时间】:2014-07-02 01:17:48
【问题描述】:
在 Chrome 浏览器中,我已经保存了用户名和密码。
现在,如果我导航到其他表单并且它包含其他内容的用户名和密码,我保存的表单会自动填充到此处。
我怎样才能阻止这种情况?
【问题讨论】:
-
@koala_dev 类似问题但不相等
标签: html struts1 auto-populate
在 Chrome 浏览器中,我已经保存了用户名和密码。
现在,如果我导航到其他表单并且它包含其他内容的用户名和密码,我保存的表单会自动填充到此处。
我怎样才能阻止这种情况?
【问题讨论】:
标签: html struts1 auto-populate
当autocomplete=off 不会阻止填写凭据时,使用以下 -
修复浏览器自动填充:只读并将 writeble 设置为焦点(单击和选项卡)。
<input type="password" readonly onfocus="this.removeAttribute('readonly');" onblur="this.setAttribute('readonly','');"/>
【讨论】:
对于火狐浏览器使用这个:
<input type="text" name="prevent_autofill" id="prevent_autofill" value="" style="display:none;" />
<input type="password" name="password_fake" id="password_fake" value="" style="display:none;" />
<input type="password" name="password" id="password" value="" />
对于 Chrome 浏览器:
使用autocomplete="new-password"
【讨论】:
请参考以下内容:
https://www.chromium.org/developers/design-documents/create-amazing-password-forms
和https://www.chromium.org/developers/design-documents/form-styles-that-chromium-understands
尝试以下方法:
<form id="login" action="signup.php" method="post">
<input type="text" autocomplete="username">
<input type="password" autocomplete="new-password">
<input type="password" autocomplete="new-password">
<input type="submit" value="Sign Up!">
</form>
【讨论】:
【讨论】:
autocomplete="off"。 AK Square Infomedia 的readonly 回答确实适用于这些情况。非常适合更新个人资料表单,您通常只希望在更改密码时发送密码。
首先尝试将密码字段设置为
autocomplete="new-password"
上述解决方案应该停止自动填写用户名和密码
注意:有时在用户名和密码上设置 autocomplete="off" 可能不起作用
【讨论】:
<textarea required="required" autocorrect="off" autocapitalize="off" name="username" class="form-control" placeholder="Your username" rows="1" cols="20" wrap="off"></textarea>
<textarea required="required" autocorrect="off" autocapitalize="off" name="password" class="form-control password" placeholder="Your password" rows="1" cols="20" wrap="off"></textarea>
@font-face {
font-family: 'password';
src: url('css/font/password.woff2') format('woff2'),
url('css/font/password.woff') format('woff'),
url('css/font/password.ttf') format('truetype');
font-weight: normal;
font-style: normal;
}
textarea.form-control {
overflow:hidden;
resize:none;
height:34px;
}
textarea.form-control.password:valid {
font-family: 'password';
}
注意事项
最后,它变成了一堆骇人听闻的黑客攻击(但它确实有效)
【讨论】: