【问题标题】:Safari overwriting email and password fields on an edit user formSafari 覆盖编辑用户表单上的电子邮件和密码字段
【发布时间】:2015-11-25 22:03:07
【问题描述】:

我有一个编辑用户表单:

<form method="post" action="index.php" />
  Email:
   <input type="text" name="email" value="user@domain.com" />
  Password:
   <input type="password" name="password" value="thesavedpassword" />
</form>

Safari 会为我覆盖我预先填写的用户名和密码,因此我添加了所有自动完成选项 - 这不起作用。

继续阅读,我听说 readonly 对某些人有效,所以我也尝试过,但仍然无效。以下是包含所有内容的代码:

<form method="post" action="index.php" autocomplete="off" />
  Email:
   <input type="text" name="email" value="user@domain.com"
      autocomplete="off" readonly onfocus="this.removeAttribute('readonly');" />
  Password:
   <input type="password" name="password" value="thesavedpassword"
      readonly autocomplete="off" onfocus="this.removeAttribute('readonly');" />
</form>

我真的不知道从这里去哪里!为什么 Safari 会覆盖已经填写的字段?

提前非常感谢!

【问题讨论】:

    标签: html autocomplete safari passwords autofill


    【解决方案1】:

    密码管理引擎将在检测到密码字段后立即启动,一旦检测到密码字段,它将在密码字段之前查找最近的文本字段,并假定该文本字段为用户名字段。

    大多数浏览器都会忽略自动完成属性,但我已经读过将它设置为“false”而不是“off”对某些人(不是我)有用。

    对此没有干净的解决方案。唯一对我有用的是引入隐藏的虚拟字段供 safari 填充。

    【讨论】:

      猜你喜欢
      • 2018-02-23
      • 1970-01-01
      • 2020-05-18
      • 2015-10-18
      • 1970-01-01
      • 1970-01-01
      • 2021-10-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多