<input autocomplete='on'>不适用于 Chrome.这是一个错误吗? [英] <input autocomplete='on'> does not work with Chrome. Is it a bug?

查看:28
本文介绍了<input autocomplete='on'>不适用于 Chrome.这是一个错误吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Chrome 的 html5 自动完成功能上挣扎了一段时间.我有一个这样的表格

I was struggling for a while on the html5 autocomplete feature of Chrome. I had a form like this

<form>
<input name='myname' type='email' autocomplete='on' />
<input type='submit' value='Submit!' onclick='transform_and_post_data();return false;'/>
</form>

当使用 Firefox 并返回到此表单时,自动完成工作正常.但不适用于 Chrome(至少版本 26 到 30).我终于发现只有在调用表单的 GET 或 POST 默认操作时才会完成表单的自动完成保存(这里由返回 false 阻止).所以我找到了一种解决方法,可以在某些情况下修复它:

When using Firefox and returning to this form autocomplete works fine. But not with Chrome (versions 26 to 30 at least). I finally found that autocomplete saving of a form is done only when calling the GET or POST default action of the form (here prevented by the return false). So I found a work around that fixes it in some situations :

 <form method='post' action='myaction'>
 <input name='myname' type='email' autocomplete='on' />
<input type='submit' value='Submit!' onclick='transform_data();'/>
</form>

只要我不需要通过 XhttpRequest 发布我的表单数据,这就会很好地工作.有人知道使用 XHR 制作 Chrome 自动完成表单的技巧吗?

This works well as long as I do not need to post my form data through an XhttpRequest. Does any one knows a trick to make Chrome autocomplete forms with XHRs?

这是 Chrome 的已知错误吗?(因为 Firefox 按预期工作)

Is it a known bug of Chrome? (as Firefox works as expected)

注意:autocomplete='on' 应该没用,因为它是输入的默认行为

Note : autocomplete='on' should be useless because it is the default behaviour of an input

推荐答案

Chrome 只会在提交时保存自动完成信息.这里有一些详细的解决方法:触发自动完成而不提交表单

Chrome will only save the autocomplete information on submit. There are some workarounds detailed here: Trigger autocomplete without submitting a form

这篇关于&lt;input autocomplete='on'&gt;不适用于 Chrome.这是一个错误吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆