etTimeout来实现setInterval

 

etTimeout来实现setInterval
 1 <script type="text/javascript">
 2 function interval(func, w, t){
 3     var interv = function(){
 4         if(typeof t === "undefined" || t-- > 0){
 5             setTimeout(interv, w);
 6             try{
 7                 func.call(null);
 8             }
 9             catch(e){
10                 t = 0;
11                 throw e.toString();
12             }
13         }
14     };
15 
16     setTimeout(interv, w);
17 };
18 
19 </script>

 

 

posted @ 2019-01-28 17:30  Mahmud(مەھمۇد)  阅读(142)  评论(0编辑  收藏  举报