您可能已经知道,Safari 有一个令人讨厌的自动填充错误,无论您是否设置,它都会填充电子邮件、用户名和密码字段autocomplete="off"
or not.
这是一个基本形式:
<form action="/" method="post">
<p>
<label>E-mail</label>
<input type="text" name="email" value="" />
</p>
<p>
<label>Password</label>
<input type="password" name="password" value="" />
</p>
</form>
...Safari 在页面加载时自动填充这些字段,干得好!
如果你把autocomplete="off"
对于字段和/或表单元素,Safari 仍然会自动填充这些字段:
<form action="/" method="post" autocomplete="off">
<p>
<label>E-mail</label>
<input type="text" name="email" value="" autocomplete="off" />
</p>
<p>
<label>Password</label>
<input type="password" name="password" value="" autocomplete="off" />
</p>
</form>
即使这样也行不通:
<form action="/" method="post" autocomplete="off">
<p>
<label>E-mail</label>
<input type="text" name="secretfield1" value="" autocomplete="off"/>
</p>
<p>
<label>Password</label>
<input type="password" name="secretfield2" value="" autocomplete="off" />
</p>
</form>
...因为 Safari 会查找这些<label>
元素,如果它们包含单词“电子邮件”,“密码”等,并继续自动填充。
啊啊啊啊!,我想,并尝试了这个:
<form action="/" method="post" autocomplete="off">
<p>
<label>%REPLACE_EMAIL_TITLE%</label>
<input type="text" name="%REPLACE_EMAIL_NAME%" value="" autocomplete="off"/>
</p>
<p>
<label>%REPLACE_PASSWORD_TITLE%</label>
<input type="password" name="%REPLACE_PASSWORD_NAME%" value="" autocomplete="off" />
</p>
</form>
...并使用 JavaScript 将 %TAGS% 替换为真实姓名。 Safari 自动填充启动。无论您是否在替换时设置 10 秒超时。
那么,这真的是唯一的选择吗?
<form action="/" method="post" autocomplete="off">
<p>
<label>That electronic postal address we all use, but can't write the title here because Safari fills this with YOUR information if you have autofill turned on</label>
<input type="text" name="someelectronicpostaladdress" value="" autocomplete="off"/>
</p>
<p>
<label>A set of characters, letters, numbers and special characters that is so secret that only you or the user you are changing it for knows, but can't write the title here because Safari sucks</label>
<input type="password" name="setofseeecretcharacters" value="" autocomplete="off" />
</p>
</form>
我希望不是?
UPDATE: @skithund 在 Twitter 中指出, that Safari 即将更新 4.0.3,其中提到“登录自动填充”。有谁知道该更新是否会解决此问题?