下面的javascipt代码,可以实现每隔一秒可弹出一个对话框,此弹出过程可待续1分钟的是1 var id=setInterval(alert("hello"),1000);
setTimeout(clearInterval(id),5*1000);
2 setInterval(function(){
alert("hello")
},1000;setTimeout(function(){
alert("hello")},5*1000);
3 setInterval(
alert("hello"),1000
);
setTimeout(clearInterval(id),5*1000);
4 var id=setInterval(function(){
alert("hello")},5*1000);
setTimeout(function(){
clearInterval(id)},5*1000);
大家帮我看下,哪个是对的,再说明下理由 thanks
setTimeout(clearInterval(id),5*1000);
2 setInterval(function(){
alert("hello")
},1000;setTimeout(function(){
alert("hello")},5*1000);
3 setInterval(
alert("hello"),1000
);
setTimeout(clearInterval(id),5*1000);
4 var id=setInterval(function(){
alert("hello")},5*1000);
setTimeout(function(){
clearInterval(id)},5*1000);
大家帮我看下,哪个是对的,再说明下理由 thanks
解决方案 »
- 通过javascript控制option属性的样式问题
- 一个奇怪的注释问题
- 求一简单(与fromCharCode相关)的编码函数
- JS 正则验证。。。 ############## 100%结贴,在线等。
- javascript 怎样取链接字符窜后面后面参数的值
- javascript 能否取得服务器的时间??
- 怎么用js读取form中的内容
- 父窗口刷新后,如何能找到子窗口?
- 高分交换javascript函数参考资料,哪位手头上有帮下.万分感谢.
- 这里下面如果没有else---return false后的代码,alert后会继续执行;????
- 鼠标滑入怎么出现一个层替换另一个层?很急 在线等
- Ext中跨域更新数据怎么办???!!!
按你的题目,1要改下
var id=setInterval('alert("hello")',1000);
setTimeout("clearInterval(id)",60*1000);
setInterval()和setTimeout()的第一个参数的字符串没加引号
setInterval([这里应该放一个函数地址或字符串],[时间(毫秒)])
这是可以的 setInterval('alert("hello")',1000); 字符串'alert("hello")'会被反射执行
setTimeout(clearInterval(id),5*1000); 错了
clearInterval() 是一个返回值为 null 的函数。所以这句话等价于 setTimeout(null,5*1000); null不能被执行2 setTimeout(function(){alert("hello")},5*1000) 这是想干嘛?不切题3 与1同样问题
setTimeout(function(){},time)