(原創) 如何每间格一段时间就执行function? (Web) (JavaScript)

 1<!-- 
 2(C) OOMusou 2006 http://oomusou.cnblogs.com
 3
 4Filename    : setInterval.htm
 5Compiler    : IE 6.0
 6Description : Run the function repeatedly after specified interval
 7Synopsis    : iTimerID = window.setTimeout(vCode, iMilliSeconds [, sLanguage])
 8Release     : 11/25/2006
 9-->
10<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
11<html xmlns="http://www.w3.org/1999/xhtml">
12<head>
13  <title></title>
14  <script language="javascript" type="text/javascript">
15    function Button1_onclick() {
16      //setTimeout("printMsg()",5000);
17      setInterval("printMsg()",1000);
18    }

19    
20    function printMsg() {
21      document.getElementById("div1").innerHTML += "Hello World!!<br>";
22    }

23  
</script>
24</head>
25<body>
26  <input id="Button1" type="button" value="button" onclick="return Button1_onclick()" />
27  <div id="div1">
28  </div>
29</body>
30</html>


See Also
如何在一段时间后,才执行function? (Web) (JavaScript)
(原創) 如何使用Timer? (.NET) (C#) (C++/CLI)

Reference
最新JavaScript完整与法参考辞典 3rd P.378, 古旗一浩 着/柯志杰 译, 博硕文化

posted on 2006-11-25 17:21  真 OO无双  阅读(1514)  评论(1编辑  收藏  举报

导航