本帖最后由 manman300 于 2010-04-15 21:14:52 编辑

解决方案 »

  1.   

    document.getElementById("apDiv"+i).style.display="block";
    代码缺少对象
      

  2.   

    楼主,我这有个思想,你是想实现图片的轮流播放,间隔几秒就换个img 的URL   把 你要的url 存入到数组中! 不知道怎么做 的 我这里有代码 ! 
      

  3.   

    setTimeout(imgChange(),1000); 这句改成setTimeout(imgChange, 1000); 
      

  4.   

    setTimeout(imgChange(),1000); 
    这只执行一次呀。
    setInterval(imgChange(),1000); 
    这是每隔一秒执行一下次吧。
      

  5.   


    <!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 language="javascript">
    var nowShow=1;
    var maxShow=3;
    function imgChange(){
    for(var i=1;i<maxShow+1;i++){   
    if(nowShow==i)
    document.getElementById("apDiv"+i).style.display="block";
    else
    document.getElementById("apDiv"+i).style.display="none";
    }
    if(nowShow!=maxShow)
    nowShow++;
    else
    nowShow=1;    
    }
    setInterval(imgChange,1000); 
    </script>
    <style type="text/css">
    <!--
    #apDiv1 {
    position:absolute;
    left:231px;
    top:13px;
    width:600;
    height:450;
    z-index:1;
    }
    #apDiv2 {
    position:absolute;
    left:231px;
    top:13px;
    width:600;
    height:450;
    z-index:2;
    }
    #apDiv3 {
    position:absolute;
    left:231px;
    top:13;
    width:600;
    height:450;
    z-index:3;
    }
    -->
    </style>
    </head><body >
    <div id="apDiv1"><img src="image/照片 098.jpg" width="600" alt="1" height="450" /></div>
    <div id="apDiv2"><img src="image/照片 103.jpg" width="600" alt="2" height="450" /></div>
    <div id="apDiv3"><img src="image/照片 128.jpg" width="600" alt="3" height="450" /></div>
    </body>
    </html>
      

  6.   

    setInterval("imgChange()",1000);  这样才对。
      

  7.   


    这位兄弟, setInterval(imgChange,1000); 这个我用了个alert的语句获取是能起作用了,但是实现不断的弹出对话框了,但是返回的值都是object类型,没有获取得到ID,图片也没变化,难道是我别的语句有问题?希指教,还有我在网上查了setTimeout(code,delay)不是每隔delay的值就会运行一次code吗?只是他会先运行setTimeout程序,然后再执行code,相比setInterval只是时间延长了而已,不知道这种说法对不对?再说setTimeout也能实现时间自动刷新的功能啊,那这个又怎么解析他只执行一次呢?
      

  8.   

    setTimeout("imgChange()",1000);   才可以      语法问题
      

  9.   

    楼上的,我知道语法是可以写成setTimeout("imgChange()",1000); 或者是setTimeout(imgChange,1000);但是关键现在是不能实现我要的效果。望知道的朋友指教,或许是我别的语句有问题。
      

  10.   

    setTimeout应该写在imgChange方法的最后一行,外部再写一个调用imgChange。
    getElementById获取的对象就是[Object]
      

  11.   

    [Quote=引用 8 楼 free_wind22 的回复:]
    HTML code<!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">
      

  12.   

    已经解决,谢谢各位,是不小心把var nowShow=1;放到imgChange()函数里了,导致每次都是显示第一张,低级错误啊~~不好意思,各位,谢谢了!