下面的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

解决方案 »

  1.   

    都不对!
    按你的题目,1要改下
    var id=setInterval('alert("hello")',1000);
    setTimeout("clearInterval(id)",60*1000);
      

  2.   

    你要待续1分钟,可你的代码都是待续5秒钟
    setInterval()和setTimeout()的第一个参数的字符串没加引号
      

  3.   

    4对1 setInterval(alert("hello"),1000);  错了
    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同样问题
      

  4.   

    setInterval(function(){},time) 
    setTimeout(function(){},time)