<head>
    <title></title>
    <script type="text/javascript" language="javascript">
        
        function chgImg(){
            var current_id = 0;
            var the_img=window.document.getElementById("myImg");
            the_img.src ="images/pic1.jpg";
            current_id++;
           setTimeout("the_img.src = images/pic2.jpg",1000);
        }
    }
    setInterval("chgImg()",1000);
    </script>
</head>
<body onload="chgImg()">
    <div>
        <img src="images/pic1.jpg" alt="" id="myImg" />
    </div>
</body>

解决方案 »

  1.   

    <!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=utf-8" />
    <title>无标题文档</title>
    <script type="text/javascript">
    function chgImg() {
    var o = document.getElementById('myImg');
    var src = o.src;
    o.src = o.getAttribute('src2');
    o.setAttribute('src2', src);
    }
    window.onload = function() {
    window.setInterval('chgImg()', 1000);
    }
    </script>
    </head><body>
    <img src="images/pic1.jpg" src2="images/pic2.jpg" id="myImg" />
    </body>
    </html>
      

  2.   


    <img src="http://www.baidu.com/img/baidu_sylogo1.gif" alt="" id="myImg" />
    <script type="text/javascript">
        function chgImg() {
            var the_img = document.getElementById("myImg");
            the_img.src = "http://www.baidu.com/img/baidu_sylogo1.gif";
            setTimeout(function(){
                the_img.src = "http://www.google.com.hk/images/srpr/logo3w.png";
            }, 1000);
        }
        setInterval(chgImg, 1000);
    </script>
      

  3.   

    不错。
    window.onload = function() {
        window.setInterval(chgImg, 1000);
    }