setTimeout(alert(1),3000)setTimeout(alert(2),3000)try
setTimeout('alert(1)',3000)setTimeout(function () { alert(2) },3000);

解决方案 »

  1.   

    setInterval我也试过了,不过setInterval的函数参数不能变化呀,不能老执行那一个参数,我参数是要变化的,就没有像什么Wait之类的??
      

  2.   

    说白了我就想执行
    re_pic(1)过3秒后执行
    re_pic(2)过3秒后执行
    re_pic(3)过3秒后执行
    re_pic(4)过3秒后执行
    re_pic(52)过3秒后执行
    re_pic(6)过3秒后执行
    re_pic(7)过3秒后执行
    re_pic(8)过3秒后执行回re_pic(1)
      

  3.   

    你加个if   else 不就可以了?
      

  4.   

    if(x == 9) {
      x=1;
      setInterval(...)
    }else {
      setInterval(...)
    }
      

  5.   

    <script type="text/javascript">
    var args = [1, 2, 3, 4, 5, 6, 7];var exec = function () {
    alert(Array.prototype.slice.call(arguments, 0).join('\n'));
    if (args[0] === args.pop()) window.clearInterval(timer);
    };var timer = window.setInterval(function () {
    exec.apply(null, args);
    }, 100);
    </script>- -
    我还以为你想要这样的呢.
    不过按照你那样说,你从exec里控制当前位置不就行了?
    为什么非要传递的参数不一样?
      

  6.   

    你可以参考这个.<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>轻量封装图片轮动</title>
    <script lanuage="javascript">
    var ImgConvert = function (imgid, linkid) {
    //构造参数
    this.imgid = imgid;
    this.linkid = linkid;
    this.cursor = 0;
    this.imgs = [];
    };ImgConvert.prototype = { constructor : ImgConvert

    , add : function (src, href) {
    //缓存图片
    return (this.imgs[this.imgs.length] = { obj : new Image, "href" : href }).obj.src = src;
    }

    , convert : function () {
    //变化
    var obj = this.imgs[this.cursor = this.cursor + 1 < this.imgs.length ? this.cursor + 1 : 0]
    , img = document.getElementById(this.imgid);

    if ('undefined' !== typeof img.style.filter) {
    //如果不支持,就不用滤镜
    img.style.filter = "blendTrans", img.filters(0).apply(), img.filters(0).play();
    }

    img.src = obj.obj.src, document.getElementById(this.linkid).href = obj.href;
    }

    , load : function () {
    //初始化成员
    var img = document.getElementById(this.imgid), i = 0, a = Array.prototype.slice.call(arguments, 0), t;

    for (; i < a.length ; i ++) { t = a[i].split('|'), this.add(t[0], t[1]); }
    }

    };var wc = new ImgConvert('img', 'link');
    wc.load(
    'http://www.google.cn/intl/zh-CN/images/logo_cn.gif|http://www.google.com/'
    , 'http://www.baidu.com/img/logo.gif|http://www.baidu.com/'
    , 'http://www.csdn.net/images/newcsdnlogo.gif|http://www.csdn.net/'
    );
    window.onload = function () { window.setInterval(function () { wc.convert(); }, 3000); };
    </script>
    </head>
    <body>
    <a id="link" href="http://www.google.com/" target="_blank">
    <img id="img" src="http://www.google.cn/intl/zh-CN/images/logo_cn.gif" border="0" alt="" />
    </a>
    </body>
    </html>
      

  7.   

    楼上的没听明白我的意思,现在不是循环的问题,是如果我这样写那些函数不是每隔3秒执行一次,而是几乎同时响应
    我就想要一个函数,能延时几秒,之后再执行下一条re_pic()函数
      

  8.   

    闭包的典型应用: function Timer(Pars)
    {
    function doTimer()
    {
    alert(Pars);
    }
    return doTimer;
    }

    var t =Timer('值'); setInterval(t,2000);
      

  9.   

    function lay(arg){
       if (arg > 3){
          arg = 0;
       }
       alert(lay);
       setTimeout(function(){lay(arg + 1);},3000)
    }
      

  10.   

    天啊,没一个让我满意的,我就想要一个真正能实现延时几秒钟执行下一条语句的方法都没有
    alert(1);alert(2);
    中间加什么能让这两个窗口弹出时间间隔5秒
      

  11.   

    alert(1) 和 alert(2) 是两个不同的进程?各自循环?你都没说明白需求如果只是一次的话setTimeout(function(){alert(1);setTimeout(function(){alert(2)},3000);},3000)
      

  12.   


    function lay(arg){
       arg ++;
       if (arg > 8){
          arg = 1;
       }
       re_pic(arg);
       setTimeout(function(){lay(arg);},3000)
    }lay(0);
      

  13.   

    我终于在下班前自己想出答案了,和楼上的仁兄基本一样,这才是我想要的答案,需求没说清楚多多见谅.
    <html>
    <head>
    <SCRIPT LANGUAGE="JavaScript">
    var i=0;
    function go_to_re()
    {
    setTimeout("go_to_re()",2000);
    i++;
    if (i==9) i=1;
    re_pic(i);
    }
    </SCRIPT>
    </head>
    <body onload="go_to_re()">
    </body>
    </html>
    其实就这很简单,多谢楼上的哥哥费心了,不过还是要给你分,楼上哥哥看上去是个好人