当键盘打开时android浏览器计时器
我遇到了这个问题,当在 Android 浏览器中打开软键盘时,异步函数不会执行。
例如:
<input type='text' id='foo'/>
....
document.getElementById("foo").addEventListener("keyup", function() {
window.setTimeout(function() { alert("1"); }, 20);
}, false);
只要您继续专注于文本输入,您就永远不会看到警报。对于 xhr 回调也是如此。如果您尝试发出 ajax 请求,则会发送请求,但在您在文本框中键入另一个字符之前,永远不会触发 oncomplete 回调。
有人知道解决方法吗?你可以看到谷歌显然有一个带有搜索建议的工作示例,尽管我还无法通过查看缩小/混淆的源代码来弄清楚他们的解决方案到底是什么。
任何见解表示赞赏,谢谢
I have run into this issue where asynchronous functions do not execute when the soft keyboard is open in the android browser.
For example:
<input type='text' id='foo'/>
....
document.getElementById("foo").addEventListener("keyup", function() {
window.setTimeout(function() { alert("1"); }, 20);
}, false);
You will never see the alert as long as you remain focused on the text input. This is true for xhr callbacks as well. If you attempt to make an ajax request, the request is sent, but the oncomplete callback is never fired until after you type another character in the textbox.
Does anyone know a workaround? You can see that Google obviously has a working example with their search suggestions, though I've not yet been able to figure out what exactly their solution is yet by looking at the minified/obfuscated source.
Any insight appreciated, Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
以 的方式使用最新的 jquery 库会
导致每次在软件键盘或硬件键盘上键入任何字母时,使用“#outputarea”选择的项目都会向上滑动。可能想尝试一下 jquery lib?跨浏览器兼容性是我不断关注它的主要原因。
Using the newest jquery lib in the style of
causes the item selected with "#outputarea" to be slid up every time - as soon as I type any letter on the software keyboard or a hardware keyboard. Might want to give the jquery lib a shot? Cross-browser compatibility is the main reason I keep going back to it.