javascript实现暂停

<!DOCTYPE HTML>
<html>
 <head>
  <title> New Document </title>
  <meta name="Generator" content="EditPlus">
  <meta name="Author" content="">
  <meta name="Keywords" content="">
  <meta name="Description" content="">
 </head>

 <body>
  <script>

function Pause(s,f){
    this.GoOn = function(n,s){
        if(n == 0){
            setTimeout(function(){GoOn(1,s);},s);
        } else{
            f();
        }
    }
    this.GoOn(0,s);
}

function testMethod(){
    alert("等待5秒");
    Pause(5000,function(){
        alert("结束!");
    });
}

</script>
<a onclick="testMethod();">开始</a>
</body>
</html>

posted @ 2014-08-01 12:01  稣惜陌  阅读(681)  评论(0编辑  收藏  举报