多数浏览器默认会缓存input的值,只有使用ctl+F5强制刷新的才可以清除缓存记录。

如果不想让浏览器缓存input的值,有2种方法:

 

方法一:

在不想使用缓存的input中添加 autocomplete="off";

eg: <input type="text" autocomplete="off" name="test" />

 

方法二:

在 input 所在的form标签中添加 autocomplete="off";

eg:

<form action="#" autocomplete="off">

<input type="text" autocomplete="off" name="test" />

</form>

 

但是有一种情况例外,就是表单中有input[type="password"],点击保存密码后,在Chrome浏览器则自动填充了用户名和密码的输入框;为了统一样式,我们需要就对Chrome的问题经行单独处理。

可以在不需要默认填写的input框中设置 autocomplete="new-password"

网上咱没有找到对其详细解释,但是发现163邮箱的登录注册是这么用的。

 

相关文章:

  • 2022-12-23
  • 2021-12-01
  • 2022-01-15
  • 2021-07-20
  • 2021-09-12
  • 2021-12-05
猜你喜欢
  • 2021-05-27
  • 2022-12-23
  • 2021-10-04
  • 2022-12-23
相关资源
相似解决方案