| 
<script type="text/javascript">
id = 0;      //Interval のID
//Start ボタンがクリックされたとき
function starts()
{   clearInterval(id);
    id=window.setInterval("upDate()",1000);
}
//Stop ボタンがクリックされたとき
function stop()
{   clearInterval(id); 
}
//starts() から setInterval() で呼び出される
function upDate()
{   var str = '現在時刻:' + (new Date()).toLocaleTimeString();
    document.getElementById("str").textContent = str;
}
</script>
</head>
<body>
<div id="str">現在時刻を表示</div>
<form name="Ctrl">
    <input type="button" value="START" onClick="starts()">
    <input type="button" value="STOP" onClick="stop()">
</form>
 |