我在输入标记中添加了autocomplete="on"
:
<input autocomplete="on" type="email">
它在Firefox中运行良好,但在Chrome中运行不正常。我该如何解决这个问题?
答案 0 :(得分:1)
您似乎需要为field-name
属性提供autocomplete
:
<input autocomplete="email" type="email" />
Chrome有一些与之相关的设置,您可能需要启用它。
此外,由于某种原因,Chrome似乎不允许autocomplete="on"
或autocomplete="field-name"
,因为这是Google的安全决定,因此有一些扩展已经完成支持它:
来源的要点是:
// Code design inspired by http://userscripts.org/scripts/show/7347 . Not
// overriding form submit prototypes like that does because I don't know of a
// good way to do this with Isolated Worlds (see http://groups.google.com/
// group/chromium-dev/browse_thread/thread/118689ceda861163/ff25578ed3585edd )
// and I'm not sure the password manager would pick it up anyway (see comment
// below).
function enableAutocomplete()
{
var snapshot = document.evaluate('//@autocomplete',
document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null),
numItems = snapshot.snapshotLength - 1;
for (var i = numItems; i >= 0; i--)
snapshot.snapshotItem(i).nodeValue = 'on';
}
// The password manager code checks for "autocomplete=off" in a callback
// from WebCore when the DOM content is loaded. It doesn't seem to be
// documented, but this callback seems to happen after in-page event listeners
// fire, and before content scripts with "run_at" = "document_end" are loaded.
// Therefore, we load this script early and then run the actual transform code
// on an appropriate event listener.
window.addEventListener('DOMContentLoaded', enableAutocomplete, false);
上述文档代码可让您像往常一样使用autocomplete
。
有关详细信息,请参阅documentation。