<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
<script>
var s;
window.οnlοad=function(){
s= window.setInterval("showtime()",1000); //表示一个定时器;1000是毫秒
}
function showtime(){
var sdom = document.getElementById("spantime");
var now = new Date();//用来的到当前的时间
var stime = now.getFullYear()+"年"+(now.getMonth()+1)+"月"
+now.getDate()+"日"+now.getHours()+"时"+now.getMinutes()+"分"
+now.getSeconds()+"秒";
sdom.innerHTML=stime;
}
function stopit(){
window.clearInterval(s);//停止定时器
//showtime();
// window.setInterval("showtime()",1000);//表示一个定时器;1000是毫秒
}
function kaishi(){
s= window.setInterval("showtime()",1000);
}
</script>
</head>
<body>
<span id="spantime"></span>
<input type="button" value="停止" οnclick="stopit();"/>
<input type="button" value="开始" οnclick="kaishi();"/>
</body>
</html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
<script>
var s;
window.οnlοad=function(){
s= window.setInterval("showtime()",1000); //表示一个定时器;1000是毫秒
}
function showtime(){
var sdom = document.getElementById("spantime");
var now = new Date();//用来的到当前的时间
var stime = now.getFullYear()+"年"+(now.getMonth()+1)+"月"
+now.getDate()+"日"+now.getHours()+"时"+now.getMinutes()+"分"
+now.getSeconds()+"秒";
sdom.innerHTML=stime;
}
function stopit(){
window.clearInterval(s);//停止定时器
//showtime();
// window.setInterval("showtime()",1000);//表示一个定时器;1000是毫秒
}
function kaishi(){
s= window.setInterval("showtime()",1000);
}
</script>
</head>
<body>
<span id="spantime"></span>
<input type="button" value="停止" οnclick="stopit();"/>
<input type="button" value="开始" οnclick="kaishi();"/>
</body>
</html>