SetTimeout (expression, delay time) is used to execute an expression after the specified delay time after loading. The number of times is one.
Setinterval (expression, interaction time) is different. It executes the expression at a specified time after loading.
If you specify the number of cycles, you can use setTimeout for each interval.
1: FunctionF (){
2: // Do something here...
3:};
4:
5: For(VaRI = 1; I <13; I ++ ){
6:SetTimeout (F, 1000 );
7:}
8:
If you want to execute the expression once at a specified time, but do not have the limit loop-round robin (until a condition is met, jump out ). SetTimeout can be triggered again in the expression to form a recurrence scheduled effect.
1: FunctionF (){
2: If(Mycondition)// Condition for jumping out of the loop
3:{
4: // Do something here...
5:SetTimeout (F, 1000 );// SetTimeout triggered by loop call
6:};
7:
8:SetTimeout (F, 1000 );
You mayArticleInterested:
- differentiate underfined, null, and Nan in Javascript
- optimize JavaScript
- extjs + ASP. NET implements a real progress bar to display the server's long-term operation progress
-
extjs + ASP. NET Implement Asynchronous Tree node search and find the next (findnext)
- extjs + ASP. NET implement tree node dragging
-
extjs + ASP. NET implement dragdrop from grid to tree
- use
Yui compressor and DOS batch processing scripts to compress JavaScript and CSS