Window objects have two main timing Methods: setTimeout and setInteval. Their syntaxes are basically the same, but their functions are different. The setTimeout method is a Timer Program, that is, after what time. After the job is finished, pull it down. The setInterval method... SyntaxHighlighter.
Window objects have two main timing Methods: setTimeout and setInteval. Their syntaxes are basically the same, but their functions are different.
The setTimeout method is a Timer Program, that is, after what time. After the job is finished, pull it down.
The setInterval method indicates that an operation is executed repeatedly at a certain interval.
If you use setTimeout to implement the setInerval function, you need to regularly call yourself in the executed program. To clear a counter, you need to call different clearing methods based on the method used:
Example: (1 ):
T = setTimeout ('northsnow () ', 1000 );
ClearTimeout (t );
(2 ):
T = setInterval ('northsnow () ', 1000 );
ClearInteval (t );
SetTimeout ()
Syntax
Var t = setTimeout ("javascript statement", millisecond );
The first parameter is a string containing a JavaScript statement. This statement may be like "alert ('5 seconds! ') ", Or call a function, such as alertMsg ()".
The second parameter indicates how many milliseconds since the current time the first parameter will be executed.
Tip: 1000 milliseconds equals one second.
Instance
When the button in the following example is clicked, a prompt box will pop up in five seconds.