js暂停

来源:互联网 发布:java try的教学 编辑:程序博客网 时间:2024/05/02 02:38
function Pause(obj,iMinSecond){  
   if (window.eventList==null) window.eventList=new Array();  
   var ind=-1;  
   for (var i=0;i<window.eventList.length;i++){  
    if (window.eventList[i]==null) {  
     window.eventList[i]=obj;  
     iind=i;  
     break;  
    }  
   }  
     
   if (ind==-1){  
    ind=window.eventList.length;  
    window.eventList[ind]=obj;  
   }  
   setTimeout("GoOn(" + ind + ")",iMinSecond);  
  }  
  /*  
  该函数把要暂停的函数放到数组window.eventList里,同时通过setTimeout来调用继续函数。  
  继续函数如下:  
  */  
  function GoOn(ind){  
   var obj=window.eventList[ind];  
   window.eventList[ind]=null;  
   if (obj.NextStep) obj.NextStep();  
   else obj();  
  }  
  function Test(){  
   alert("hellow");  
   Pause(this,3000);
   this.NextStep=function(){  
    alert("NextStep");  
   }  
  }