只要copy下保存到一共html文件里,一点击就知道了,其实有很多都是选择的,真正其作用的代码不多阿。

解决方案 »

  1.   

    太长啦,不知道你出的错误在那里,你看看这里的代码
    脚本说明:
    第一步:把如下代码加入<head>区域中
    <SCRIPT LANGUAGE="JavaScript">
    <!--
    var bV=parseInt(navigator.appVersion);
    var NS4=(document.layers) ? true : false;
    var IE4=((document.all)&&(bV>=4))?true:false;
    var ver4 = (NS4 || IE4) ? true : false;function expandIt(){return}
    function expandAll(){return}
    function nomsg(){self.status="";}if(ver4){
      document.write("<SCR"+"IPT LANGUAGE=\"JavaScript\" SRC=\"rsmenu.js\"></SCR"+"IPT>");
    }
    //-->
    </SCRIPT>第二步:把如下代码加入<body>区域中
    <span class="label"></span><br>
    <!---------- begin OUTLINE -----------> 
    <!--上方全部展开/关闭-->
    <A HREF="#" onClick="expandAll(false); return false"><IMG NAME="imEx" SRC="bullet-plus.gif" WIDTH=9 HEIGHT=9 BORDER=0 ALT="展开或关闭全部菜单"><FONT STYLE="font-size: 9pt">展开/关闭全部</FONT></A>
    <!-- <BLOCKQUOTE> --> <!--第一级父菜单-->
    <DIV ID="elOneParent" CLASS=parent style="margin-left: 0.1px">
    <TABLE BORDER=1 CELLSPACING=0 CELLPADDING=0 WIDTH=101><tr><td class=label>
    <A HREF="#" style="color:#FFFF00; text-decoration:none;"  onClick="expandIt('elOne'); return false"><IMG NAME="imEx" SRC="bullet-plus.gif" WIDTH=9 HEIGHT=9 BORDER=0 ALT="展开全部菜单"> 主菜单一
    </a></td></tr></table>
    </DIV>
    <!--第一级子菜单-->
    <DIV ID="elOneChild" CLASS=child style="margin-left: 0.5px">
    <TABLE BORDER=1 CELLSPACING=0 CELLPADDING=0 WIDTH=96>
    <tr><td>
            <A HREF="1.htm" target="data">连接页面1</A><BR>
    </td></tr><tr><td>
            <A HREF="2.htm" target="data">连接页面2</A><BR>
    </td></tr><tr><td>
    <A HREF="3.htm" target="data">连接页面3</A><BR>
    </td></tr><tr>
          <td height="12"> <A HREF="4.htm" target="data">连接页面4</A> </td>
        </tr></table>
    </DIV><!--第二级父菜单-->
    <DIV ID="elTwoParent" CLASS=parent style="margin-left: 0.1px">
    <TABLE BORDER=1 CELLSPACING=0 CELLPADDING=0 WIDTH=101><tr><td class=label>
    <A HREF="#" style="color:#FFFF00; text-decoration:none;"  onClick="expandIt('elTwo'); return false"><IMG NAME="imEx" SRC="bullet-plus.gif" WIDTH=9 HEIGHT=9 BORDER=0 ALT="展开全部菜单"> 主菜单二
    </a></td></tr></table>
    </DIV><!--第二级子菜单-->
    <DIV ID="elTwoChild" CLASS=child style="margin-left: 0.5px">
    <TABLE BORDER=1 CELLSPACING=0 CELLPADDING=0 WIDTH=96>
    <tr><td>
            <A HREF="1.htm" target="data">连接页面1</A><BR>
    </td></tr><tr><td>
            <A HREF="2.htm" target="data">连接页面2</A><BR>
    </td></tr><tr><td>
    <A HREF="3.htm" target="data">连接页面3</A><BR>
    </td></tr><tr><td>
    <A HREF="4.htm" target="data">连接页面4</A>
    </td></tr></table>
    </DIV><!--第三级父菜单-->
    <DIV ID="elThreeParent" CLASS=parent style="margin-left: 0.1px">
    <TABLE BORDER=1 CELLSPACING=0 CELLPADDING=0 WIDTH=101><tr><td class=label>
    <A HREF="#" style="color:#FFFF00; text-decoration:none;"  onClick="expandIt('elThree'); return false"><IMG NAME="imEx" SRC="bullet-plus.gif" WIDTH=9 HEIGHT=9 BORDER=0 ALT="展开全部菜单"> 主菜单三
    </a></td></tr></table>
    </DIV><!--第三级子菜单-->
    <DIV ID="elThreeChild" CLASS=child style="margin-left: 0.5px">
    <TABLE BORDER=1 CELLSPACING=0 CELLPADDING=0 WIDTH=96>
    <tr><td>
            <A HREF="1.htm" target="data">连接页面1</A><BR>
    </td></tr><tr><td>
            <A HREF="2.htm" target="data">连接页面2</A><BR>
    </td></tr><tr><td>
    <A HREF="3.htm" target="data">连接页面3</A><BR>
    </td></tr><tr><td>
    <A HREF="4.htm" target="data">连接页面4</A>
    </td></tr></table>
    </DIV><!--第四级父菜单-->
    <DIV ID="elFourParent" CLASS=parent style="margin-left: 0.1px">
    <TABLE BORDER=1 CELLSPACING=0 CELLPADDING=0 WIDTH=101><tr><td class=label>
    <A HREF="#" style="color:#FFFF00; text-decoration:none;"  onClick="expandIt('elFour'); return false"><IMG NAME="imEx" SRC="bullet-plus.gif" WIDTH=9 HEIGHT=9 BORDER=0 ALT="展开全部菜单"> 主菜单四
    </a></td></tr></table>
    </DIV><!--第四级子菜单-->
    <DIV ID="elFourChild" CLASS=child style="margin-left: 0.5px">
    <TABLE BORDER=1 CELLSPACING=0 CELLPADDING=0 WIDTH=96>
    <tr><td>
            <A HREF="1.htm" target="data">连接页面1</A><BR>
    </td></tr><tr><td>
            <A HREF="2.htm" target="data">连接页面2</A><BR>
    </td></tr><tr><td>
    <A HREF="3.htm" target="data">连接页面3</A><BR>
    </td></tr><tr><td>
    <A HREF="4.htm" target="data">连接页面4</A>
    </td></tr></table>
    </DIV><!--第五级父菜单-->
    <DIV ID="elFiveParent" CLASS=parent style="margin-left: 0.1px">
    <TABLE BORDER=1 CELLSPACING=0 CELLPADDING=0 WIDTH=101><tr><td class=label>
    <A HREF="#" style="color:#FFFF00; text-decoration:none;"  onClick="expandIt('elFive'); return false"><IMG NAME="imEx" SRC="bullet-plus.gif" WIDTH=9 HEIGHT=9 BORDER=0 ALT="展开全部菜单"> 主菜单五
    </a></td></tr></table>
    </DIV><!--第五级子菜单-->
    <DIV ID="elFiveChild" CLASS=child style="margin-left: 0.5px">
    <TABLE BORDER=1 CELLSPACING=0 CELLPADDING=0 WIDTH=96>
    <tr><td>
            <A HREF="1.htm" target="data">连接页面1</A><BR>
    </td></tr><tr><td>
            <A HREF="2.htm" target="data">连接页面2</A><BR>
    </td></tr><tr><td>
    <A HREF="3.htm" target="data">连接页面3</A><BR>
    </td></tr><tr><td>
    <A HREF="4.htm" target="data">连接页面4</A>
    </td></tr></table>
    </DIV><!--第六级父菜单-->
    <DIV ID="elSixParent" CLASS=parent style="margin-left: 0.1px">
    <TABLE BORDER=1 CELLSPACING=0 CELLPADDING=0 WIDTH=101><tr><td class=label>
    <A HREF="#" style="color:#FFFF00; text-decoration:none;"  onClick="expandIt('elSix'); return false"><IMG NAME="imEx" SRC="bullet-plus.gif" WIDTH=9 HEIGHT=9 BORDER=0 ALT="展开全部菜单"> 主菜单六
    </a></td></tr></table>
    </DIV><!--第六级子菜单-->
    <DIV ID="elSixChild" CLASS=child style="margin-left: 0.5px">
    <TABLE BORDER=1 CELLSPACING=0 CELLPADDING=0 WIDTH=96>
    <tr><td>
            <A HREF="1.htm" target="data">连接页面1</A><BR>
    </td></tr><tr><td>
            <A HREF="2.htm" target="data">连接页面2</A><BR>
    </td></tr><tr><td>
    <A HREF="3.htm" target="data">连接页面3</A><BR>
    </td></tr><tr><td>
    <A HREF="4.htm" target="data">连接页面4</A>
    </td></tr></table>
    </DIV><!-- </BLOCKQUOTE> -->
    <!--下方全部展开/关闭-->
    <DIV ID="elExpParent" CLASS=regular> <A HREF="#" onClick="expandAll(true); return false"><IMG NAME="imEx" SRC="bullet-plus.gif" WIDTH=9 HEIGHT=9 BORDER=0 ALT="展开/关闭全部">展开/关闭全部</A> </DIV><!---------- end OUTLINE -----------><br><SCRIPT LANGUAGE="JavaScript1.2">
    <!--
    if(NS4){
      firstEl = "elOneParent";
      firstInd = getIndex(firstEl);
      showAll();
      arrange();
    }
    //-->
    </SCRIPT>
      

  2.   

    我没有细看,错误好像是缺少对象,把这几句img加上id=imEx至少不会出错,再具体的功能实现你再自己研究吧
      <A HREF="1.htm" target="data"><img id=imEx src="../images1/bullet-plus.gif" WIDTH=10 HEIGHT=10>新建用户</A><BR>       
           
      <A HREF="2.htm" target="data"><img id=imEx src="../images1/bullet-plus.gif" WIDTH=10 HEIGHT=10>修改密码</A><BR>       
           
      <A HREF="3.htm" target="data"><img id=imEx src="../images1/bullet-plus.gif" WIDTH=10 HEIGHT=10>删除用户</A><BR>
      

  3.   

    错在expandAll函数的最后几句
    for (i=0; i<imColl.length; i++) {
    imColl(i).src = newSrc;
    }
    这里
      

  4.   

    你没有定义imEx对象,改如下:
    <A HREF="#" style="color:#000080; text-decoration:none;" onClick="expandIt('elOne'); return false;"><img 
    src="../images1/bullet-plus.gif" WIDTH=10 HEIGHT=10>用户管理</A> 
    -->
    <A HREF="#" style="color:#000080; text-decoration:none;" onClick="expandIt('elOne'); return false;"><img 
    src="../images1/bullet-plus.gif" WIDTH=10 HEIGHT=10 id="imEx" name="imEx">用户管理</A>
      

  5.   

    全部修正之后,如下:
    <html>
    <SCRIPT LANGUAGE="JavaScript"> var isExpanded = false; function getIndex(el) {
       ind = null;
       for (i=0;i<document.layers.length; i++) {
    whichEl = document.layers[i];
    if (whichEl.id == el) {
       ind = i;
       break;
    }
       }
       return ind;
    } function arrange() {
       nextY = document.layers[firstInd].pageY + document.layers[firstInd].document.height;
       for (i=firstInd+1; i<document.layers.length; i++) {
    whichEl = document.layers[i];
       if (whichEl.visibility != "hide") {
    whichEl.pageY = nextY;
    nextY += whichEl.document.height;
       }
       }
    } function initIt(){
       if (NS4) {
    for (i=0; i<document.layers.length; i++) {
       whichEl = document.layers[i];
    if (whichEl.id.indexOf("Child") != -1) whichEl.visibility = "hide";
    }
    arrange();
       }
       else {
    tempColl = document.all.tags("DIV");
    for (i=0; i<tempColl.length; i++) {
       if (tempColl(i).className == "child") tempColl(i).style.display = "none";
    }
       }
    } function expandIt(el) {
       if (!ver4) return;
       if (IE4) {expandIE(el)} else {expandNS(el)}
    } function expandIE(el) { 
       whichEl = eval(el + "Child");
       whichIm = event.srcElement;    if (whichEl.style.display == "none") {
    whichEl.style.display = "block";
    whichIm.src = "../images1/bullet-minus.gif";
       }
       else {
    whichEl.style.display = "none";
    whichIm.src = "../images1/bullet-plus.gif";
       }
    } function expandNS(el) {
       whichEl = eval("document." + el + "Child");
       whichIm = eval("document." + el + "Parent.document.images['imEx']");
       if (whichEl.visibility == "hide") {
    whichEl.visibility = "show";
    whichIm.src = "../images1/bullet-minus.gif";
       }
       else {
    whichEl.visibility = "hide";
    whichIm.src = "../images1/bullet-plus.gif";
       }
       arrange();
    } function showAll() {
       for (i=firstInd; i<document.layers.length; i++) {
    whichEl = document.layers[i];
    whichEl.visibility = "show";
       }
    } function expandAll(isBot) {
       newSrc = (isExpanded) ? "../images1/bullet-plus.gif" : "../images1/bullet-minus.gif";    if (NS4) {
    document.images["imEx"].src = newSrc;
    for (i=firstInd; i<document.layers.length; i++) {
    whichEl = document.layers[i];
    if (whichEl.id.indexOf("Parent") != -1) {
       whichEl.document.images["imEx"].src = newSrc;
    }
    if (whichEl.id.indexOf("Child") != -1) {
       elOneParent.visibility = (isExpanded) ? "hide" : "show";
    }
    } arrange();
    if (isBot && isExpanded) scrollTo(0,document.layers[firstInd].pageY);
       }
       else {
    divColl = document.all.tags("DIV");
    for (i=0; i<divColl.length; i++) {
    if (divColl(i).className=="parent") {
       divColl(i).style.display = (isExpanded) ? "none" : "block";
    }
    }
    imColl = document.images.item("imEx");
    for (i=0; i<imColl.length; i++) {
    imColl(i).src = newSrc;
    }    }    isExpanded = !isExpanded;
    } with (document) {
       write("<STYLE TYPE='text/css'>");
       if (NS4) {
    write(".parent {position:absolute; visibility:hidden}");
    write(".child {position:absolute; visibility:hidden}");
    write(".regular {position:absolute; visibility:hidden}")
       }
       else {
    write(".child {display:none}")
       }
       write("</STYLE>");
    } onload = initIt; var bV=parseInt(navigator.appVersion); var NS4=(document.layers) ? true : false; var IE4=((document.all)&&(bV>=4))?true:false; var ver4 = (NS4 || IE4) ? true : false; function nomsg(){
    self.status="";
    } if(ver4){   document.write("<SCR"+"IPT LANGUAGE=\"JavaScript\" SRC=\"cd011.js\"></SCR"+"IPT>"); } </SCRIPT>
    <!---------- begin OUTLINE -----------> 
    <A HREF="#" onClick="expandAll(false); return false;"><img src="../images1/bullet-plus.gif" WIDTH=10 HEIGHT=10 ALT="展开/关闭全部">
    <FONT COLOR="#008000">权限管理</FONT></A>
    <!-- <span style="background: #00FFFF; color: black">展开/关闭全部</span> -->        
           
    <!-- <BLOCKQUOTE> --> <!-- 第一级父菜单 -->        
           
    <DIV ID="elOneParent" CLASS=parent style="margin-left: 0.5em;display:none;">       
           
    <A HREF="#" style="color:#000080; text-decoration:none;" onClick="expandIt('elOne'); return false;"><img src="../images1/bullet-plus.gif" WIDTH=10 HEIGHT=10 id="imEx" name="imEx">用户管理</A>       
           
    </DIV>       
           
           
           
    <!-- 第一级子菜单 -->       
           
    <DIV ID="elOneChild" CLASS=child style="margin-left: 1em;display:none;">       
           
      <A HREF="1.htm" target="data"><img src="../images1/bullet-plus.gif" WIDTH=10 HEIGHT=10>新建用户</A><BR>       
           
      <A HREF="2.htm" target="data"><img src="../images1/bullet-plus.gif" WIDTH=10 HEIGHT=10>修改密码</A><BR>       
           
      <A HREF="3.htm" target="data"><img src="../images1/bullet-plus.gif" WIDTH=10 HEIGHT=10>删除用户</A><BR>       
           
    </DIV>         
           <!---------- end OUTLINE ----------->       
           
    </html>
      

  6.   

    imColl = document.images.item("imEx");
    imEx没有定义,看看吧,楼上说的是对的
      

  7.   

    imColl初始化了没有?好像是null,在javascript中使用数组时,要注意数组元数个数的问题,一个和多个的初始化是不一样的。