我一直在玩 Android 的 Kik 网络应用程序。我注意到某些事件在用户与页面交互之前不会正确触发。
这个问题在 Kik 中表现出来,但它也出现在我运行 Android 4.4/KitKat 的 Galaxy S5 上的股票网络浏览器中。
HTML
<script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
click here: <button id="button">a button</button>
<br><br><br>
textbox: <input type="text" id="textbox">
CSS
* {
font-size: 20px;
}
JavaScript
window.onload=function(e) {
// set function to button.click
$('#button').click(function() {
fucus();
});
// run the exact same function rightey-right now
$('#textbox').focus();
// run it again in three minutes
$('#textbox').focus()
};
function fucus() {
$('#textbox').focus();
}