时间:2021-07-01 10:21:17 帮助过:9人阅读
<script type=”text/javascript”>
//循环执行,每隔3秒钟执行一次showalert()
window.setInterval(showalert, 3000);
function showalert()
{
alert(“aaaaa”);
}
//定时执行,5秒后执行show()
window.setTimeout(show,5000);
function show()
{
alert(“bbb”);
}
</script>
B.当要执行的方法中需要参数时
代码如下:
<script type=”text/javascript”>
//循环执行,每隔3秒钟执行一次 showalert()
window.setInterval(function(){
showalert(“aaaaa”);
}, 3000);
function showalert(mess)
{
alert(mess);
}
//定时执 行,5秒后执行showalert()
window.setTimeout(function(){
showalert(“bbbbbb”);
},5000);
</script>