setInterval

I read in a few places that setInterval and setTimeout don’t work in IE, but I’ve used them in IE 6,7 and 8, so what am I missing here? Is this some special condition? I’m not surprised IE causes a problem - I just want to know when it occurs.

It was suggested you have to quote and use brackets, such as setInterval(“myFunc()”,2000); but I tried it without and it still works - i.e. setInterval(myFunc,2000) works fine in IE 6, even. Oddly, I had trouble with this at one time and thought it was lack of quotes and brackets, but it now works all the time. Is it a bad idea to omit the quotes and brackets? Here’s a jQuery script for simple font expansion that works fine in IE6. I’m just wondering where the problem might arise:


<script type="text/javascript">
   jQuery(function(){     
       var setint, cnt=0;
       var target = jQuery('div#garble p');
       var fontsize = parseFloat(target.css('font-size'));
       function boobaw(){jQuery('#garble p').css('font-size',(fontsize+=1) + 'px');if(++cnt>15) clearInterval(setint)} 
       jQuery('button#clikme').click(function(){setint=setInterval(boobaw,500)});
    });
</script>
<button id="clikme">clikme!</button>
<div id="garble"><p>grow me, please</p></div>

I have never come across any suggestion that setInterval doesn’t work in any version of IE. All the code I have ever written using it has worked in every version of IE that I ever tested it in.

setInterval(myFunc,2000) is preferable to setInterval(“myFunc()”,2000) because it saves the step of converting the string into a function.

Here’s the link that mentions this - webreflection.blogspot.com/2007/06/simple-settimeout-setinterval-extra.html Maybe he has a different meaning.

It works, but I didn’t make it a live link since the system is killing any replies with a link until I have five posts :wink: