|Property/method value type:||Number primitive|
|-||myWindow.setInterval(aFunction, anInterval, someArguments)|
|-||myWindow.setInterval(aFunction, anInterval, someArguments, aLanguage)|
|-||myWindow.setInterval(aSourceText, anInterval, someArguments)|
|-||myWindow.setInterval(aSourceText, anInterval, someArguments, aLanguage)|
|-||setInterval(aFunction, anInterval, someArguments)|
|-||setInterval(aFunction, anInterval, someArguments, aLanguage)|
|-||setInterval(aSourceText, anInterval, someArguments)|
|-||setInterval(aSourceText, anInterval, someArguments, aLanguage)|
|Argument list:||aFunction||A function object|
|aLanguage||A scripting language to execute the script source (MSIE only)|
|anInterval||A time interval in milliseconds|
|aSourceText||Some valid script source text|
|someArguments||The arguments to the function object (not supported in MSIE version 4)|
The setInterval() method establishes a periodically scheduled execution timer that runs the same fragment of script continuously with a delay timer between each cycle.
If you only want to delay the execution of some code and you want it to be executed just once, then use the setTimeout() method instead. That will defer execution and clear its timer automatically when it executed.
Passing a function as one of the arguments is only supported in MSIE from version 5.0 upwards and Netscape Navigator from version 4 upwards. You can only specify the scripting language in MSIE however.
The simpler form in which a script source text can be passed in a string with a second argument to specify the interval is much more portable and recommended for use. You can pass a multiple line script fragment in this argument as long as each line is separated by a semi-colon. Functionally, this is very similar to the eval() method with an extra repeat periodicity value.
Be careful that you note the value returned by this method if you intend to deactivate the periodic execution. Without that value, you have no way to identify which one of possibly several timers you want to cancel, and take care not to cancel the timer more than once. Cancelling a non-existent periodic timer or deferred action is likely to crash your browser.
The result of this method is an identifying value that can be used with the clearInterval() method to cancel this periodic execution.
On the other hand, implementing something that is non-portable across the MSIE and Netscape Navigator browsers is a bad idea anyway.
Be careful how you operate on these interval timers. You can store an identifier, which you can later use to cancel the timer. However, if the timer has already been fired, some browsers may crash due to you trying to cancel a non-existent timer.