当前位置: 首页 > 网络学院 > 客户端脚本教程 > HTML DOM > HTML DOM setTimeout() 方法
The setTimeout() method is used to call a function or evaluate an expression after a specified number of milliseconds.
setTimeout()方法可用来在每个指定毫秒间隔后调用一个函数或是表达式
setTimeout(code,millisec,lang) |
| Parameter 参数 | Description 描述 |
|---|---|
| code | Required. A pointer to a function or the code to be executed 必选。指定函数或是要执行的代码 |
| millisec | Required. The number of milliseconds to wait before executing the code 必选。执行代码所要等待的毫秒数 |
| lang | Optional. The scripting language: JScript | VBScript | JavaScript 可选。脚本语言类型 |
<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> |
Simple timing
简单的计时
Another simple timing
另一种计时
Timing event in an infinite loop
循环计时
Timing event in an infinite loop - with a Stop button
带停止按钮的循环计时
A clock created with a timing event
建立一个时钟的效果。
评论 (0) All