<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!--
var ms = 0;
var state = 0;
var fun=0;
var tmp1 = "0";
function start_wtc() {
if (state == 0) {
state = 1;
then = new Date();
then.setTime(then.getTime() - ms);
} else {
state = 0;
now = new Date();
ms = now.getTime() - then.getTime();
tmp_str=ms.toString();
tmp_len=tmp_str.length;
if (tmp_len > 3) {
tmp_pos=tmp_str.length - 3;
tmp1 = tmp_str.substring(0,tmp_pos);
tmp2 = tmp_str.substring(tmp_pos,tmp_str.length);
document.stp_watch.time.value = fun+' : '+tmp1+' : '+tmp2;
}else{
document.stp_watch.time.value = fun+' : '+tmp1+' : '+ms;
}
}
}
function wt_reset() {
state = 0;
ms = 0;
fun = 0;
document.stp_watch.time.value = ms;
}
function wt_display() {
setTimeout("wt_display();", 50);
if (state == 1) {
now = new Date();
ms = now.getTime() - then.getTime();
tmp_str=ms.toString();
tmp_len=tmp_str.length;
if (tmp_len > 3) {
tmp_pos=tmp_str.length - 3;
tmp1 = tmp_str.substring(0,tmp_pos);
tmp2 = tmp_str.substring(tmp_pos,tmp_str.length);
document.stp_watch.time.value = fun+' : '+tmp1+' : '+tmp2;
}else{
document.stp_watch.time.value = fun+' : '+tmp1+' : '+ms;
}
}
}
//-->
</SCRIPT>
</HEAD>
<BODY onLoad="wt_display()">
<CENTER>
<FORM NAME="stp_watch">
<table border=1 cellpadding=4 bgcolor=#ffffe8>
<tr><td colspan=3 align=center bgcolor=blue>
<font color=yellow size=4 face = "century"><i>Stop Watch</i>
</td></tr>
<tr><td>
経過時間:
<INPUT TYPE="text" Name="time" size=20>
</td><td>
<INPUT TYPE="BUTTON" Name="ssbutton" VALUE="Start/Stop" onClick="start_wtc()">
</td><td>
<INPUT TYPE="BUTTON" NAME="reset" VALUE="Reset" onClick="wt_reset()">
</td></tr></table>
</FORM>
</CENTER>
</BODY>
</HTML>
|