这个函数,就不应该这么用,正确的方法是:function test(param){
    setInterval(function(){
       alert(param)
    },1000);
}

解决方案 »

  1.   

    <html>
    <head>
    <script language="javascript">

    function test(n){
    alert(n);
    }
    function fu(nn)
    {
    window.setInterval("test('nn')", 1000);
    }

    </script>
    </head>
    <body>
    <button onclick="fu('shishi')">just do it</button>
    </body>
    </html>
      

  2.   

    先谢谢噢但是这样,我传不进来能变的变量?例如那个shishi,根本传不进来
      

  3.   

    重写一个呗:var ws = window.setInterval;
    window.setInterval = function(){
      var foo;
      var time = arguments[1];
      var scope = arguments[2];
      if(typeof arguments[0] == "string"){
        foo = new Function(arguments[0]);
      }else if(typeof arguments[0] == "function"){
        foo = arguments[0]
      }
      var args = [];
      for(var i=3;i<arguments.length;i++){
        args[i-3] = arguments[i];
      }
      ws(function(){
        foo.apply(scope,args)
      },time);
    }
    function test(a,b,c){
    alert(a+b+c);
    }setInterval(test,3000,window,2,3,4);  //参数1:函数指针 参数2:时间  参数3:作用域,默认是window  参数n(n>3):你的变量
      

  4.   

    setInterval("test("+你的变量+")",3000)