<input type="button" value="开始计时!" onclick="timedCount()">
<input type="text" id="txt">
<input type="button" value="停止计时!" onclick="stopCount()">
<script type="text/javascript">
var c = 0;
var t;
timedCount();
function timedCount() {
document.getElementById('txt').value = c;
c = c + 1;
t = setTimeout("timedCount()", 1000);
}
function stopCount() {
clearTimeout(t);
}
</script>