I believe timers (setInterval()) are suspended when the app enters the background. You could do something like:
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);
You may need to adjust those time intervals to suite your needs.
But, most likely, if it has been long enough to need a refresh (a few days) safari will probably reload the page because it is out of memory.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…