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}
}
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 阅读(366) 评论(0) 编辑 收藏 举报