我一直在为Android安装Kik网络应用程序。我注意到在用户与页面进行交互之前,某些事件无法正确触发。
该问题在Kik上得到了体现,但在运行Android 4.4 / KitKat的Galaxy S5上的股票Web浏览器中也出现了。
的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();
}
.focus()
除非从用户交互事件中进行调用,否则大多数移动浏览器都无法正常运行。例如,如果您在某个onclick
事件中调用它,它将起作用,但是如果在事件中被调用,onload
它将不起作用。这并非特定于Kik,而是一般而言的移动浏览器。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句