源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

延时重复执行函数 lLoopRun.js

  • 时间:2022-09-21 01:20 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:延时重复执行函数 lLoopRun.js
公司的一个项目中,有许多地方需要延时执行一些可重复性的函数(动作),就写了下面这段函数。 呵呵,不知道取什么意思更为确切些,就定为了:LoopRun,意为“重复执行”  function lLoopRun(sFuncLoop,sFuncEnd,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;     }   }   window.clearInterval(vintervalId);   vintervalId = window.setInterval(this._doLoop,delayTime); } 参数说明: sFuncLoop >> 字符串型,需要重复执行的Javascript函数或语句(多个函数或语句请用;分隔) sFuncEnd >> 字符串型,用于中止重复执行动作(sFuncLoop)的Javascript函数或语句 nDelay >> 数字型,重复执行的时间间隔(毫秒数) [b]应用实例:[/b] 水平往复运动: [url=http://cnlei.iecn.net/mycode/lLoopRun/index.html]http://cnlei.iecn.net/mycode/lLoopRun/index.html[/url] 自动伸缩大小: [url=http://cnlei.iecn.net/mycode/lLoopRun/index2.html]http://cnlei.iecn.net/mycode/lLoopRun/index2.html[/url] 垂直往复运动: [url=http://cnlei.iecn.net/mycode/lLoopRun/index3.html]http://cnlei.iecn.net/mycode/lLoopRun/index3.html[/url] 渐变显示(图片): [url=http://cnlei.iecn.net/mycode/lLoopRun/index4.html]http://cnlei.iecn.net/mycode/lLoopRun/index4.html[/url] 以上只是几个简单的应用实例,具体应用时关键还得看sFuncLoop和sFuncEnd这两个参数所代表的函数写得是否好,例如给实例一中的运动图片加上缓冲运行的效果的话,就需要在sFuncLoop所代表的函数中加上相应的实现代码:)
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部