回复内容:
iOS 上利用后端 JS 不执行的特性,加一个心跳机制,判断超时即在后台
var lastFired = new Date().getTime();
setInterval(function() {
now = new Date().getTime();
if(now - lastFired > 5000) { // if it's been more than 5 seconds
alert("onfocus");
}
lastFired = now;
}, 500);
查看更多关于在移动端上,JS如何能知道浏览器已经被切换到后台了?的详细内容...
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://haodehen.cn/did66192