态度决定高度、企图决定版图、格局决定结局

导航

javascript stopwatch


.Net中有个stopwatch非常方便,这里写个js的,简单用用

    function stopWatcher(){
    
var timerRunning=false;
    
var startTime;
    
var endTime;
}
;
stopWatcher.prototype 
= {
    start:
function(){
        
this.startTime = new Date().getTime();
        
this.timerRunning=true;
    }
,
    stop:
function(){
        
this.endTime = new Date().getTime();
        
this.timerRunning = false;
    }
,
    reset:
function(){
        
this.startTime = null;
        
this.endTime = null;
        
this.timerRunning = false;
    }
,
    isRunning : 
function(){return this.timerRunning},
    escapeTime :
function(){return this.endTime - this.startTime}
}

posted on 2008-01-30 00:11  flyingchen  阅读(363)  评论(0编辑  收藏  举报