javascript: blinking image problem
Posted: Wed Nov 24, 2004 11:03 am
i'm doing some simple effect with js...
above code should create blinking image that blinks fast each single time and there is 1000ms pause between separate blinks
but it doesn't work:image stays not visible...
if i interchange lines (a) and (b) then it works(actually f.style.display="none"; becomes redundent line)
i suspect that there are certain optimizations in js parser that interfere with my code in some way
i tried also to put alert() after each f.style.display line and then script worked as i planned...
does anyone knows what's going on?
Code: Select all
<!--html-->
<img src="images/fire.png" id="fire" />
/*css*/
#fire{
position:absolute;top:140px;left:100px;
display:none;
}
//javascript
delay=100;
timer=window.setInterval("blinkImg()",1000);
function blinkImg()
{
f=document.getElementById("fire");
(a) f.style.display="block";
for(i=1;i<delay;i++) // creates delay between blinks
dummy=0;
(b) f.style.display="none";
}but it doesn't work:image stays not visible...
if i interchange lines (a) and (b) then it works(actually f.style.display="none"; becomes redundent line)
i suspect that there are certain optimizations in js parser that interfere with my code in some way
i tried also to put alert() after each f.style.display line and then script worked as i planned...
does anyone knows what's going on?