setTimeOut setInterval clearTimeOut
2009-11-12 14:02
316 查看
瞄一眼这些Js函数setTimeOut setInterval clearTimeOut,蒙了。为什么呢?
当然是概念混淆了!刚查了一下,做个纪念先:
setInterval("js code",time):每隔time时间执行一次其所指定的js Code。
setTimeOut("jscode",time):time之后执行一次....【仅仅执行一次】
clearTimeOut("settimeout的引用"):清除setTimeOut计时器。
1 <html>
2 <head></head>
3 <body>
4 <div id="intime"></div>
5 <div id="timeouttime"></div>
6 <script type="text/javascript">
7 function showtime(ele){
8 timer=new Date();
9 document.getElementById(ele).innerHTML=timer.getHours()+":"+timer.getMinutes()+":"+timer.getSeconds();
10 }
11 setTimeout("showtime('timeouttime')",1000);
12 setInterval("showtime('intime')",1000);
13 </script>
14 </body>
15 </html>
当然是概念混淆了!刚查了一下,做个纪念先:
setInterval("js code",time):每隔time时间执行一次其所指定的js Code。
setTimeOut("jscode",time):time之后执行一次....【仅仅执行一次】
clearTimeOut("settimeout的引用"):清除setTimeOut计时器。
1 <html>
2 <head></head>
3 <body>
4 <div id="intime"></div>
5 <div id="timeouttime"></div>
6 <script type="text/javascript">
7 function showtime(ele){
8 timer=new Date();
9 document.getElementById(ele).innerHTML=timer.getHours()+":"+timer.getMinutes()+":"+timer.getSeconds();
10 }
11 setTimeout("showtime('timeouttime')",1000);
12 setInterval("showtime('intime')",1000);
13 </script>
14 </body>
15 </html>
相关文章推荐
- js中setInterval/clearInterval与setTimeout/clearTimeout
- js中setInterval/clearInterval与setTimeout/clearTimeout
- 让JavaScript中计时器setTimeout/setInterval的回调方法支持参数传递
- what is the difference between the setTimeout and setInterval
- js setInterval setTimeout 方法区别
- Juqery 定时器 settimeout setInterval
- JS黑魔法之this, setTimeout/setInterval, arguments
- JavaScript 的数值转换 和计时器 setInterval clearInterval
- web.xml中的session-timeout元素与session.setMaxInactiveInterval()函数 的区别和使用
- 定时器 setTimeout setInterval
- session-timeout(web.xml)元素与session.setMaxInactiveInterval()函数
- Javascript 调度: setTimeout and setInterval
- 定时器的简单示例(setInterval clearInterval)
- setTimeout setInterval 区别 javascript线程解释
- JS setTimeout clearTimeout
- JavaScript Timers with setTimeout and setInterval
- JavaScript Timers with setTimeout and setInterval
- setTimeout & setInterval
- js setTimeout and setInterval
- 【javascript基础】【setTimeout setInterval】 之 How JavaScript Timers Work [译]