This function works well in IE and Firefox. But with Chrome, the alert is displayed before all the other commands have been executed, which is a nonsense because the user doesn’t even have a chance to see what happened before the alert comes on. Of course the alert is freezing everything else, but it comes too quick. How do I prevent this behaviour. Here’s my code:
function crash(cr)
{
cj=cj+1; var j=document.images[cj]; B.src=“pxtransp.gif”; b.width=1; b.height=1; j.src=“X.gif”; j.style.position=“absolute”; j.style.left=crashx; j.style.top=crashy; j.width=29; j.height=29;
alert(collision);
}
You could wrap alert
in setTimeout
:
setTimeout(() => {
alert(collision)
}, 0)
Thanks Jenov. It works fine with a 500ms timeout. Just what I needed.
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.