Can Mobile Safari run JavaScript while my phone is in sleep-mode?
As a test, I wrote some JavaScript to count every 1 second and display it.
CODE:
// define function and counter
var counter = 1;
function update_me() {
setTimeout(function(){
// update element
document.getElementById('counter').innerHTML = counter;
counter++;
update_me();
}, 1000);
}
// run code
update_me();
CODE: END
It works great when I keep Safari active, but my problem occurs in sleep-mode. I can view the counter, but as soon as I hit the button on the top of my phone the counter stops, even though Safari is running in the background. I can hit the button again, slide the bar and see the counter continue where it left off.
I'd like to know if its possible to keep JavaScript running while the phone is sleeping.
Thanks in advance everyone,
-Dane
3GS, iPhone OS 3.1.2