function lLoopRun(sFuncLoop,sFuncEnd,nDelay) {
//writen by http://fengyan.iecn.cn
//sFuncLoop >> 字符串型,需要重复执行的Javascript函数或语句(多个函数或语句请用;分隔)
//sFuncEnd >> 字符串型,用于中止重复执行动作(sFuncLoop)的Javascript函数或语句
//nDelay >> 数字型,重复执行的时间间隔(毫秒数)
var vintervalId = null;
var runString = sFuncLoop;
var stopString = sFuncEnd;
var delayTime = nDelay;
//var nCount = 0;//执行次数//为便于测试,应用时就将此行注释掉
this._doLoop = function (){
if (vintervalId && !eval(stopString)){
eval(runString);
//nCount ;//记录执行次数//为便于测试,应用时就将此行注释掉
} else {
window.clearInterval(vintervalId);
vintervalId = null;
}
//document.getElementById("TestCount").innerHTML = nCount;//输出执行次数//为便于测试,应用时就将此行注释掉
}
window.clearInterval(vintervalId);
vintervalId = window.setInterval(this._doLoop,delayTime);
}
几个实例代码:
水平往复运动:
执行次数:
0