Window对象 setInterval()方法应用

setInterval()方法用于在指定的毫秒数时间间隔内重复执行指定的函数或表达式;

例如:

 1 <html>
 2   <head>  
 3     <title>测试setInterva方法</title>
 4   </head>
 5   
 6   <body>   
 7     <br><span id="test"></span>
 8     <script type="text/javascript">
 9         var msg = "欢迎使用js!";
10         function showmsg(){
11             n = msg.length;
12             msg = msg.substring(1)+msg.substring(0,1);
13             
14             x= document.getElementById("test");
15             x.innerHTML = msg;
16             return;
17         }
18         setInterval("showmsg()",1000);
19     </script>
20   </body>
21 </html>

 

posted on 2018-01-02 17:10  humbird  阅读(987)  评论(0编辑  收藏  举报

导航