In mobile safari on iPhone or iPod Touch if a user clicks on a mailto link and then returns to the page (either send or cancel), timers no longer function inside of javascript. I've posted a bug to apple, and on openradar.
However, I was wondering if anyone out there has come across this before and come up with some sort of workaround.
update: Here is some sample code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Testing</title>
</head>
<body>
<h1 id="normal">Normal: 0</h1>
<h1 id="timed">Timed: 0</h1>
<h1 id="interval">Interval: 0</h1>
<a id="clicker">Click Me</a><br />
<a href="mailto:">Mail To</a>
<script type="text/javascript">
window.addEventListener('load', function ()
{
var count = 0;
var interval = 0;
var id;
document.getElementById('clicker').addEventListener('click', function () {
interval = 0;
count++;
document.getElementById('normal').innerHTML = 'Normal: ' + count;
setTimeout(function () {document.getElementById('timed').innerHTML = 'Timed: ' + count; }, 100);
id = setInterval(function ()
{
interval++;
if(interval > 5)
{
clearInterval(id);
return;
}
document.getElementById('interval').innerHTML = 'Interval: ' + interval;
}, 200);
}, false);
}, false);
</script>
</body>
</html>
To clear up some apparent confusion about what I'm saying is a bug, its not that when you leave the page and return any timers that had been running have stopped, this is to be expected. The problem is that once a user returns to the page if you start new timers, they will never fire.