PDA

View Full Version : Help : SetInterval , SetTimeOut , ClearInterval


quocbao
06-01-2005, 10:09 PM
Anyone help me :

SetInterval , SetTimeOut , ClearInterval

What're these functions ? And what are their usage ?

Plz help me , i'm a newbie

RysChwith
06-02-2005, 08:36 AM
SetInterval and ClearInterval are used for timing purposes. Whereas a standard function call executes the function immediately, one on setInterval executes after the specified amount of time. You then use clearInterval to cancel the repetition, so that it doesn't go on forever.

The difference between setInterval and setTimeout, as I understand them, is that setInterval creates a repeating function call which needs to be cancelled, while setTimeout only fires once.

The usage is:setTimeout( "functionname()", delay_in_milliseconds );
var myInterval = setInterval( "functionname()", delay );
clearInterval( myInterval );Rys