-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtime_setTimeout.js
More file actions
43 lines (36 loc) · 1.07 KB
/
time_setTimeout.js
File metadata and controls
43 lines (36 loc) · 1.07 KB
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
43
/*
* @由于个人水平有限, 难免有些错误, 还请指点:
* @Author: cpu_code
* @Date: 2020-08-12 12:43:29
* @LastEditTime: 2020-08-12 16:23:06
* @FilePath: \web\time_setTimeout\time_setTimeout.js
* @Gitee: [https://gitee.com/cpu_code](https://gitee.com/cpu_code)
* @Github: [https://github.com/CPU-Code](https://github.com/CPU-Code)
* @CSDN: [https://blog.csdn.net/qq_44226094](https://blog.csdn.net/qq_44226094)
* @Gitbook: [https://923992029.gitbook.io/cpucode/](https://923992029.gitbook.io/cpucode/)
*/
var stop_flag = 0;
function timeout()
{
var time = new Date();
var h = time.getHours();
var m = time.getMinutes();
var s = time.getSeconds();
document.getElementById("time").value = h+":"+m+":"+s;
//指定的毫秒数后调用函数timeout
// 设置超时调用函数, 超时后自动调用所设置的函数
stop_flag = setTimeout("timeout()", 1000);
}
function start_onload()
{
timeout();
}
function stop()
{
//通过setTimeout返回值,停止定时
clearTimeout(stop_flag);
}
function start()
{
timeout();
}