I've the same problem depicted in iOS 5 pauses JavaScript when tab is not active thread.
我的问题是,当我回到暂停的标签时,是否会被注意到。
onfocus
并且onblur
事件不适用于要暂停的选项卡。
编码:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script src="http://code.jquery.com/jquery-1.7.1.min.js" ></script>
<script type="text/javascript">
window.onblur = function () {
console.log("blur");
$("#whatevent").append("blur<br/>");
}
window.onfocus = function () {
console.log("focus");
$("#whatevent").append("focus<br/>");
}
window.onunload = function () {
console.log("unload");
$("#whatevent").append("unload<br/>");
}
window.onload = function () {
console.log("load");
$("#whatevent").append("load<br/>");
}
</script>
</head>
<body>
<div id="whatevent"></div>
</body>
</html>
没有但onload
(但仅在我第一次加载页面时)事件在我切换选项卡时在 iPad 上有效。