-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtimerDemo.html
More file actions
42 lines (42 loc) · 864 Bytes
/
Copy pathtimerDemo.html
File metadata and controls
42 lines (42 loc) · 864 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<html>
<head>
<title>网页秒表计时器</title>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
var ms = 0;
var state = 0;
function startstop() {
if (state == 0) {
state = 1;
then = new Date();
then.setTime(then.getTime() - ms);
} else {
state = 0;
now = new Date();
ms = now.getTime() - then.getTime();
document.stpw.time.value = ms;
}
}
function swreset() {
state = 0;
ms = 0;
document.stpw.time.value = ms;
}
function display() {
setTimeout("display();", 50);
if (state == 1) {now = new Date();
ms = now.getTime() - then.getTime();
document.stpw.time.value = ms;
}
}
// End -->
</SCRIPT>
<body onLoad="display()">
<FORM NAME="stpw">
开始计时:
<INPUT TYPE="text" Name="time">
<INPUT TYPE="BUTTON" Name="ssbutton" VALUE="开始/停止" onClick="startstop()">
<INPUT TYPE="BUTTON" NAME="reset" VALUE="重置" onClick="swreset()">
</FORM>
</body>
</html>