这段代码是滑动门的代码,测试时提示img_obj[...].src' 为空或不是对象
请高手解惑解惑,万分感激
代码如下:<script type="text/javascript">
var cont = document.getElementById('content');
var img_obj = cont.getElementsByTagName('img');
var title_obj = cont.getElementsByTagName('span');
var link_obj = cont.getElementsByTagName('p');
document.getElementById('bigimg').innerHTML = '<a href='+link_obj[0].childNodes[0].href+' target=_blank><img src='+img_obj[0].src+'></a>';
document.getElementById('title').innerHTML = title_obj[0].innerHTML;
//输出缩略图
for (var j=0;j<4;j++)
{
document.getElementById('thumb').innerHTML +='<a href=javascript:voids('+j+');><img src='+img_obj[j].src+' class=pic id=thumb'+j+' title='+img_obj[j].title+'></a>';
}
//void函数
function voids(id)
{
document.getElementById('title').innerHTML = title_obj[id].innerHTML;
}
//void函数end
//自动轮换播放
var i= 0;
function playimg(){
var id=i%4;
document.getElementById('bigimg').innerHTML = '<a href='+link_obj[id].childNodes[0].href+' target=_blank><img src='+img_obj[id].src+'></a>';
document.getElementById('title').innerHTML = title_obj[id].innerHTML;
i=i+1;
}
setInterval(playimg,3000);
//自动轮换播放end//推拉门
function menu_on(x,id,y)
{
for(i=1;i<=y;i++)
{
document.getElementById("menu_"+x+"_"+i+"_"+y).className = "menu_off";
document.getElementById("cont_"+x+"_"+i+"_"+y).style.display = "none";
}
document.getElementById("menu_"+x+"_"+id+"_"+y).className = "menu_on";
document.getElementById("cont_"+x+"_"+id+"_"+y).style.display = "block";
}
//推拉门end</SCRIPT>

解决方案 »

  1.   

    给点html片段 。只给点JS看不出什么毛病的 。
    自己用FIREBUG看看 。
      

  2.   

    <!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" />
    <meta http-equiv="X-UA-Compatible" content="IE=7" />
    <title>xx</title>
    <meta name="description" content="xx" />
    <meta name="keywords" content="xx" />
    <meta name="author" content="xx" />
    <meta name="copyright" content="xx" />
    <meta name="robots" content="all" />
    <link rel="Book" href="[!--news.url--]style/images/favicon.ico" />
    <link rel="Shortcut Icon" href="[!--news.url--]style/images/favicon.ico" />
    <link href="[!--news.url--]style/css/index.css" rel="stylesheet" type="text/css" />
    <link href="[!--news.url--]style/css/head.css" rel="stylesheet" type="text/css" />
    <link href="[!--news.url--]style/css/foot.css" rel="stylesheet" type="text/css" />
    <noscript><iframe src=*.html></iframe></noscript>
    <script> 
      window.onload=function(){ 
      var sw=window.screen.width; 
      if(sw<1100) {document.getElementById("content").style.fontSize = "0.875em"} 
      else if (sw<1500) {document.getElementById("content").style.fontSize = "1em"} 
      else {document.getElementById("content").style.fontSize = "1.125em"}; 
      } 
    </script>
    </head>
    <body leftMargin="0" topMargin="0">
    <!-- 头部 -->
    <div class="cont_960"><div id="login_1"></div>
    <div id="login_2">
    <ul class="login_2_1">
    <script src="[!--news.url--]e/member/login/loginjs.php"></script>
    <li><img src="[!--news.url--]style/images/006.gif" id="sc" alt="xx"/>&nbsp;</li>
    <li><a href="javascript:window.external.AddFavorite('[!--news.url--]', 'xx')" style="color:rgb(255,255,255)">xx</a>&nbsp;&nbsp;&nbsp;</li>
    <li><img src="[!--news.url--]style/images/007.gif" id="lx" alt="xx"/>&nbsp;</li>
    <li><a id="asp99" style="color:#FFF;">xx</a><script language=Javascript src="[!--news.url--]style/js/gb2big5.js"></script></li>
    </ul>
    </div>
    <div id="login_3"></div>
    <div id="links_1"></div>
    <div id="links_2">
    <div id="logo"><img src="[!--news.url--]style/images/logo.gif" alt="束河旅游网,束河古镇官方网站,丽江市古城区束河古镇景区管理委员会" /></div>
    <div id="menu">
    <ul class="menu_1">
    <li class="cd1"><a href="[!--news.url--]" title="网站首页" target="_self">xx</a></li>
    </ul>
    <ul class="menu_2">
    <li class="cd3"><a href="[!--news.url--]column3/qixiqingrenjie/" title="七夕情人节" target="_self">情&nbsp;人&nbsp;节</a></li>
    </ul>
    <ul class="menu_3">
    <li class="cd1"><a href="[!--news.url--]Topics/Service/index.html" title="客服中心" target="_self">客服中心</a></li>
    <li class="cd3"><a href="[!--news.url--]column3/guojijiubajie/" title="国际酒吧节" target="_self">酒&nbsp;吧&nbsp;节</a></li>
    </ul>
    </div>
    </div>
    <div id="links_3"></div>
    <div id="search">
    <div id="kefu"><a href="[!--news.url--]Topics/Service/Contact/" target="_self"><img src="style/images/008.gif" alt="束河古镇景区客服中心" /></a></div>
    <div id="qq">
    <ul class="lxqq">
    <embed src="[!--news.url--]old_shuhe/m/music/dewplayer.swf" width="60" height="20" type="application/x-shockwave-flash" quality="high" wmode="transparent" flashvars="son=[!--news.url--]old_shuhe/m/music/HuiJia.mp3|[!--news.url--]old_shuhe/m/music/JiuGe.mp3|[!--news.url--]old_shuhe/m/music/NaXiSanBuQu.mp3|[!--news.url--]old_shuhe/m/music/MaMaTianNa.mp3|[!--news.url--]old_shuhe/m/music/Na5.mp3|[!--news.url--]old_shuhe/m/music/Na4.mp3|[!--news.url--]old_shuhe/m/music/Na6.mp3|[!--news.url--]old_shuhe/m/music/Na7.mp3|[!--news.url--]old_shuhe/m/music/Na8.mp3|[!--news.url--]old_shuhe/m/music/Na9.mp3|[!--news.url--]old_shuhe/m/music/Na10.mp3|[!--news.url--]old_shuhe/m/music/Na11.mp3&autoplay=1&autoreplay=0&showtime=1&volume=100">
    </ul>
    </div>
    <form name="searchform" method="post" action="[!--news.url--]e/search/index.php" target="_self">
    <div id="ss">
    <input name="keyboard" type="text" id="text3" size="10">&nbsp;
    <input type="hidden" name="show" value="keyboard">
    <input name="Submit" type="image" src="[!--news.url--]style/images/009.gif" align="absmiddle" />
    </div>
    </form>
    </div>
    <div id="ying"><img src="[!--news.url--]style/images/010.gif" /></div>
    <div class="kong8"></div>
    </div>
    <!-- 头部 -->
    <div style="clear:both"></div>
    <div class="cont_960">
    <!-- ad1 -->
    <div>
    <DIV style="WIDTH:696px; HEIGHT:85px; float:left;"><a href="[!--news.url--]Topics/HBar/" title="xx" target="_self"><img src="[!--news.url--]style/ad_img/haligu.gif" width="696" height="85"></a></DIV>
    <DIV style="WIDTH:246px; HEIGHT:85px; margin-left:8px; float:right;"><a href="http://www.conifer-lijiang.com/" title="xx" target="_self"><img src="[!--news.url--]style/ad_img/kangnian.gif" width="246" height="85"></a></DIV>
    </div>
    <div style="clear:both"></div>
    <div class="kong8"></div>
    <!-- 导航 -->
    <div id="nav">
    <span><font color="#FF0000">今天是:<script src="[!--news.url--]style/js/today.js" type="text/javascript"></script>
    </font></span>
    <div>
    便捷服务: 
     
    </div>
    </div>
    <div style="clear:both;"></div>
    <!-- 导航 -->
    <div class="kong8"></div>
    <!-- ad1 end -->
    <!-- 第一屏 -->
    <div class="left">
    <!-- 头图幻灯 -->
    <div id="content" style="display:none;">
    [ecmsinfo]'37,39',4,40,0,12,13,1[/ecmsinfo]
    <!--[ecmsinfo]栏目ID/专题ID,显示条数,标题截取数,是否显示栏目名,操作类型,模板ID,只显示有标题图片[/ecmsinfo]-->
    </div>
    <DIV id="Slide">
    <DIV id="img_show">
    <DIV id="flashtrans"></DIV>
    <DIV id="titlebg">
    <DIV id="title"></DIV>
    </DIV>
    <DIV id="bigimg"></DIV>
    </DIV>
    <DIV id="thumb"></DIV>
    </DIV>
    <!-- 头图幻灯 -->
    <div class="kong8"></div>
    <div class="l1">
    <div class="l_tt" style="background-image:url([!--news.url--]style/images/title_l1_bg.gif);">
    <h5><a href="[!--news.url--]" title="xx" target="_self">xx</a></h5>
    <span><a href="[!--news.url--]" title="xx" target="_self"><img src="[!--news.url--]style/images/more.gif" alt="xx"></a></span></div>
    <div class="l_wz">
    <ul>
    [ecmsinfo]'6,7,8',4,34,0,0,15,0[/ecmsinfo]
    <!--[ecmsinfo]栏目ID/专题ID,显示条数,标题截取数,是否显示栏目名,操作类型,模板ID,只显示有标题图片[/ecmsinfo]-->
    </ul>
    </div>
    <div id="l_img">
    [ecmsinfo]'6,7,8',2,24,0,2,16,1[/ecmsinfo]
    </div>
    </div>
    </div>
    <div class="middle">
    <div id="tt">
    <div id="tt1">
    [ecmsinfo]'2,3,4',1,32,0,12,14,0[/ecmsinfo]
    </div>
    <div id="tt2">
    <ul>
    [ecmsinfo]'2,3,4',8,36,0,0,17,0[/ecmsinfo]
    </ul>
    </div>
    </div>
    <div class="kong8"></div>
    <div class="l1">
    <div class="l_tt">
    <h5><a href="[!--news.url--]column1/mingrenfangwen/" title="xx" target="_self">xx</a></h5>
    <span><a href="[!--news.url--]column1/mingrenfangwen/" title="xx" target="_self"><img src="[!--news.url--]style/images/more.gif" alt="xx"></a></span></div>
    <div class="l_wz">
    <ul>
    [ecmsinfo]5,4,34,0,0,15,0[/ecmsinfo]
    <!--[ecmsinfo]栏目ID/专题ID,显示条数,标题截取数,是否显示栏目名,操作类型,模板ID,只显示有标题图片[/ecmsinfo]-->
    </ul>
    </div>
    <div id="m_img">
    [ecmsinfo]5,2,24,0,2,16,1[/ecmsinfo]
    </div>
    </div>
    </div>
    <div class="right">
    <div style="margin-bottom:11px; padding:8px 10px 8px 10px; border:solid #c1eafc 1px;">
    <object id="player" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" name="player" width="224" height="136">
    <param name="movie" value="[!--news.url--]style/player/player-viral.swf" />
    <param name="allowfullscreen" value="true" />
    <param name="allowscriptaccess" value="always" />
    <param name="flashvars" value="file=[!--news.url--]player/video.flv&image=[!--news.url--]style/player/shuheshiping.gif" />
    <embed
    type="application/x-shockwave-flash"
    id="player2"
    name="player2"
    src="[!--news.url--]player/player-viral.swf" 
    width="224" 
    height="136"
    allowscriptaccess="always" 
    allowfullscreen="true"
    flashvars="file=[!--news.url--]style/player/video.flv&image=[!--news.url--]style/player/shuheshiping.gif" 
    />
    </object>
    <!--<img src="images/shsp.jpg" width="256" alt="">--></div>
    <div class="r0"><div class="r0_tt">
    <h5><a href="[!--news.url--]column2/lvyouzhinan/" title="xx" target="_self">xx</a></h5>
    <span><a href="[!--news.url--]column2/lvyouzhinan/" title="xx" target="_self"><img src="[!--news.url--]style/images/more.gif" alt="xx"></a></span></div>
    <div class="r_cf">
    <ul>
    <li><a href="[!--news.url--]" title="xx-xx" target="_self">xx-xx</a></li></ul>
    </div>
    </div>
    <div class="kong8"></div>
    <div id="r_ad1">
    <div class="kong8"></div>
    <div class="r_ads">
    <DIV id="div_ad_1_704" style="WIDTH:228px; HEIGHT:72px;"><img src="[!--news.url--]style/ad_img/zhao.gif" height="72" width="228" alt="ss"></DIV>
    </div>
    <div class="kong8"></div>
    <div class="r_ads">
    <DIV id="div_ad_1_705" style="WIDTH:228px; HEIGHT:72px;"><img src="[!--news.url--]style/ad_img/shuhe.gif" height="72" width="228" alt="xx"></DIV>
    </div>
    <div class="kong8"></div>
    <div class="r_ads">
    <DIV id="div_ad_1_705" style="WIDTH:228px; HEIGHT:72px;"><img src="[!--news.url--]style/ad_img/zhuanti.gif" height="72" width="228" alt="xx"></DIV>
    </div><div class="kong8"></div>
    </div>
    </div>
    </div>
    <!-- 第一屏end -->
    <div style="clear:both"></div>
    <!-- 第二屏 -->
    <div class="cont_960">
    <div class="kong8"></div>
    <!-- ad2 -->
    <div>
    <DIV id="div_ad_1_702" style="WIDTH:950px; HEIGHT:80px;"><img src="[!--news.url--]style/AD_img/yx.gif" width="950" height="80" alt="束河印象酒店"></DIV>
    </div>
    <!-- ad2 end -->
    <div class="kong8"></div>
    <div class="left">
    <div class="l1" style="height:338px;overflow:hidden;">
    <div class="l_tt"><h5><a href="[!--news.url--]column2/shuhegaishu/" title="xx" target="_self">xx</a></h5>
    <span><a href="[!--news.url--]column2/shuhegaishu/" title="xx" target="_self"><img src="[!--news.url--]style/images/more.gif" alt="XX"></a></span></div>
    <div id="syzt">
    <div class="syzt_pic">
    [phomeflashpic]10,8,310,200,0,0,2,3[/phomeflashpic]<br><a href="[!--news.url--]column2/shuhegaishu/" title="XX" target="_self">XX</a></div>
    <div id="shbj">
    <div class="bj">
    <div><a href="[!--news.url--]column2/shuhegaishu/2009-12-25/268.html" title="XX" target="_self">XX</a></div>
    </div>
    </div>
    </div>
      

  3.   


    <ul class="foot2">
    <li class="foot2_1"><a href="http://XX" target="_self">XX</a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="STYLE11">|</span>&nbsp;&nbsp;&nbsp;&nbsp;<a href="http://XX" target="_self">XX</a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="STYLE11">|</span>&nbsp;&nbsp;&nbsp;&nbsp;<a href="http://XX" target="_self">XX</a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="STYLE11">|</span>&nbsp;&nbsp;&nbsp;&nbsp;<a href="http://XX" target="_self">XX</a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="STYLE11">|</span>&nbsp;&nbsp;&nbsp;&nbsp;<a href="http://XX" target="_self">艺术团</a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="STYLE11">|</span>&nbsp;&nbsp;&nbsp;&nbsp;<a href="[!--news.url--]Topics/Sitemap/index.html" target="_self">XX</a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="STYLE11">|</span>&nbsp;&nbsp;&nbsp;&nbsp;<a href="[!--news.url--]e/public/Flink/flink_add.php" target="_self">XX&nbsp;</a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="STYLE11">|</span>&nbsp;&nbsp;&nbsp;&nbsp;<a href="[!--news.url--]e/web/?type=rss2" target="_self">RSS&nbsp;<img src="[!--news.url--]style/images/rss.gif" /></a></li>
    </ul>
    </div><div id="footc">
    <div id="footc_1"><span class="STYLE5">XX</span>69850575 <span class="STYLE5">XX:</span>0888-5174636 <span class="STYLE5">XX:</span>0888-5136619 </div>
    <div id="footc_2">XX        </div>
    <div id="footc_3">XX</div>
    <div id="footc_4">XX<script src="http://s139.cnzz.com/stat.php?id=8511734&web_id=851173&show=pic" language="JavaScript" charset="gb2312"></script></div>
    <div id="footc_5">版权所有·<a href="[!--news.url--]">XX</a> Copygight &copy; 2003-2009 <a href="[!--news.url--]">XX</a> XXCP备案:<a href="http://www.miibeian.gov.cn" target="_self">XX</a></div>
    </div><div id="footphoto">
    <li class="footphoto_1"><img src="[!--news.url--]style/images/12321.gif" alt="12321网络不良与垃圾信息举报受理" />&nbsp;&nbsp;</li>
    <li class="footphoto_2"><!--<a href="http://116.52.153.140" target="_self">--><img src="[!--news.url--]style/images/net110.gif" alt="云南省公安厅信息网络安全报警服务网站" />&nbsp;&nbsp;</li>
    <li class="footphoto_3"><img src="[!--news.url--]style/images/jubao.gif" alt="不良信息举报中心" /><br /><br /><br /></li>
    </div>
    </div><script type="text/javascript">
    var cont = document.getElementById('content');
    var img_obj = cont.getElementsByTagName('img');
    var title_obj = cont.getElementsByTagName('span');
    var link_obj = cont.getElementsByTagName('p');
    document.getElementById('bigimg').innerHTML = '<a href='+link_obj[0].childNodes[0].href+' target=_blank><img src='+img_obj[0].src+'></a>';
    document.getElementById('title').innerHTML = title_obj[0].innerHTML;
    //输出缩略图
    for (var j=0;j<4;j++)
    {
    document.getElementById('thumb').innerHTML +='<a href=javascript:voids('+j+');><img src='+img_obj[j].src+' class=pic id=thumb'+j+' title='+img_obj[j].title+'></a>';
    }
    //void函数
    function voids(id)
    {
    document.getElementById('title').innerHTML = title_obj[id].innerHTML;
    }
    //void函数end
    //自动轮换播放
    var i= 0;
    function playimg(){
    var id=i%4;
    document.getElementById('bigimg').innerHTML = '<a href='+link_obj[id].childNodes[0].href+' target=_blank><img src='+img_obj[id].src+'></a>';
    document.getElementById('title').innerHTML = title_obj[id].innerHTML;
    i=i+1;
    }
    setInterval(playimg,3000);
    //自动轮换播放end//推拉门
    function menu_on(x,id,y)
    {
    for(i=1;i<=y;i++)
    {
    document.getElementById("menu_"+x+"_"+i+"_"+y).className = "menu_off";
    document.getElementById("cont_"+x+"_"+i+"_"+y).style.display = "none";
    }
    document.getElementById("menu_"+x+"_"+id+"_"+y).className = "menu_on";
    document.getElementById("cont_"+x+"_"+id+"_"+y).style.display = "block";
    }
    //推拉门end</SCRIPT>
    <div style="display:none;"><script src="http://s139.cnzz.com/stat.php?id=8511734&web_id=851173&show=pic" language="JavaScript" charset="gb2312"></script></div></body>
    </html>
    这个是完整的代码,检查过了,就是没找到错误的地方在那个地方,是帝国cms的代码