Possible Duplicate:
Chrome: timeouts/interval suspended in background tabs?
It works correctly while we remain on the same tab, but as we change the tab, setTimeout responds weirdly in Chrome. I guess it has some connection with window.blur event.
Following is the code:
function animate(_travel, elementID)
{
OB = document.getElementById(elementID);
getNumber = OB.style.marginLeft.replace("px", "") * 1;
ease = Math.ceil(_travel / 8);
OB.style.marginLeft = (getNumber - ease) + "px";
_travel -= ease;
if(_travel > 0) {
setTimeout("animate(" + _travel + ", '" + elementID + "')", 15);
}
}
animate(300, 'myDiv');