当前位置: 首页 > 网络学院 > 客户端脚本教程 > HTML DOM > HTML DOM setTimeout() 方法

HTML DOM
DOM TableRow 对象
DOM Textarea 对象
DOM Window 对象

HTML DOM setTimeout() 方法


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-03-04   浏览: 340 ::
收藏到网摘: n/a

Definition and Usage
定义与用法

The setTimeout() method is used to call a function or evaluate an expression after a specified number of milliseconds.
setTimeout()方法可用来在每个指定毫秒间隔后调用一个函数或是表达式

Syntax 语法

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
可选。脚本语言类型


Example 举例

<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

登陆 | 还没注册?