定义和用法setTimeout() 方法用于在指定的毫秒数后调用函数或计算表达式。 注意大小写 语法setTimeout(code,millisec)
提示和注释提示:setTimeout() 只执行 code 一次。如果要多次调用,请使用 setInterval() 或者让 code 自身再次调用 setTimeout()。 <html> <head> <script type="text/javascript"> function timedMsg() {var t=setTimeout("alert('5 seconds!')",5000)} </script> </head> <body> <form> <input type="button" value="Display timed alertbox!" onClick="timedMsg()"> </form> <p>Click on the button above. An alert box will be displayed after 5 seconds.</p> </body> </html> |
|
来自: johnny_net > 《javascript》