转自:http://www.w3school.com.cn/jsref/met_win_settimeout.asp
1.setTimeout() 方法用于在指定的毫秒数后调用函数或计算表达式。
1 <html>
2 <head>
3 <script type="text/javascript">
4 function timedMsg()
5 {
6 var t=setTimeout("alert('5 seconds!')",5000)
7 }
8 </script>
9 </head>
10
11 <body>
12 <form>
13 <input type="button" value="显示计时的消息框!" onClick = "timedMsg()">
14 </form>
15 <p>点击上面的按钮。5 秒后会显示一个消息框。</p>
16 </body>
17
18 </html>
来源:https://www.cnblogs.com/sharpest/p/6145256.html