JSP中存在两种:
只执行一次的定时器
<script>
//定时器 异步运行
function hello(){
alert("hello");
}
//使用方法名字执行方法
var t1 = window.setTimeout(hello,1000);
var t2 = window.setTimeout("hello()",3000);//使用字符串执行方法
window.clearTimeout(t1);//去掉定时器
</script>
重复执行的定时器
<script>
function hello(){
alert("hello");
}
//重复执行某个方法
var t1 = window.setInterval(hello,1000);
var t2 = window.setInterval("hello()",3000);
//去掉定时器的方法
window.clearInterval(t1);
</script>
页面中经常存在有效果没显示的情况,这时候我们要调整定时器的时间间隔,或者定时器里套一个定时器函数等等,只要可以实现,没有什么不可以