Skills of the javascript delayed repeated execution function looprun. js_javascript
Source: Internet
Author: User
What is the repeated execution function of javascript latency? 1.1.23 function looprun (sFuncLoop, sFuncEnd, nDelay ){
// Writen by http://fengyan.iecn.cn
// SFuncLoop> string type, Javascript Functions or statements that need to be executed repeatedly (use; To separate multiple functions or statements)
// SFuncEnd> string type, used to stop Javascript Functions or statements that execute repeated actions (sFuncLoop)
// NDelay> Number type, recurrence interval (in milliseconds)
Var vintervalId = null;
Var runString = sFuncLoop;
Var stopString = sFuncEnd;
Var delayTime = nDelay;
// Var nCount = 0; // number of executions // to facilitate testing, comment out this line during the application
This. _ doLoop = function (){
If (vintervalId &&! Eval (stopString )){
Eval (runString );
// NCount ++; // record the execution times. // This line is commented out when the application is used for testing.
} Else {
Window. clearInterval (vintervalId );
VintervalId = null;
}
// Document. getElementById ("TestCount"). innerHTML = nCount; // number of output executions // comment out this line for ease of test
}
Window. clearInterval (vintervalId );
VintervalId = window. setInterval (this. _ doLoop, delayTime );
}
Several instance codes:
Horizontal Reciprocating Motion:
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service