新书推介:《语义网技术体系》
作者:瞿裕忠,胡伟,程龚
   >>中国XML论坛<<     W3CHINA.ORG讨论区     计算机科学论坛     SOAChina论坛     Blog     开放翻译计划     新浪微博  
 
  • 首页
  • 登录
  • 注册
  • 软件下载
  • 资料下载
  • 核心成员
  • 帮助
  •   Add to Google

    >> XML网站展示,XML源代码,XML编程示例。 本版仅接受原创、转贴、网站展示,具体的技术交流请前往各相关版块。
    [返回] 中文XML论坛 - 专业的XML技术讨论区XML.ORG.CN讨论区 - XML技术『 XML源码及示例(仅原创和转载) 』 → 请教个关于菜单的问题 查看新帖用户列表

      发表一个新主题  发表一个新投票  回复主题  (订阅本版) 您是本帖的第 5973 个阅读者浏览上一篇主题  刷新本主题   树形显示贴子 浏览下一篇主题
     * 贴子主题: 请教个关于菜单的问题 举报  打印  推荐  IE收藏夹 
       本主题类别:     
     lichanghui 帅哥哟,离线,有人找我吗?
      
      
      等级:大一(高数修炼中)
      文章:21
      积分:139
      门派:XML.ORG.CN
      注册:2005/7/13

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给lichanghui发送一个短消息 把lichanghui加入好友 查看lichanghui的个人资料 搜索lichanghui在『 XML源码及示例(仅原创和转载) 』的所有贴子 引用回复这个贴子 回复这个贴子 查看lichanghui的博客楼主
    发贴心情 请教个关于菜单的问题

    以前的精华帖里有个关于菜单的代码,是这样的
    navigater.xsl
    <?xml version="1.0" encoding="GB2312"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
    <!-- 无限深度菜单 -->
    <!--
    如果使用本代码请保留以下版权信息.
    本代码由Forlan编写, Soft@benheco.com
    -->
    <xsl:template match="/">
      <html>
       <head>
        <title>Navigater</title>
        <style>
         <xsl:comment>
         <![CDATA[
          td { border-style: solid; border-width: 0 }
         !]]>
         </xsl:comment>
        </style>
        <script language="javascript">
        <xsl:comment>
        <![CDATA[
        function OppNode(ParentNodeImg,Node)
        {
         if(Node.style.display == "none")
         {
          Node.style.display = "block";
          ParentNodeImg.src = "image/e.gif";
         }
         else
         {
          Node.style.display = "none";
          ParentNodeImg.src = "image/c.gif";
         }
        }
        function OpenURL(URL)
        {
         parent.RightFrame.location = URL;
        }
        ]]>
        </xsl:comment>
        </script>
       </head>
       <body topmargin="10" leftmargin="10" marginheight="10" marginwidth="10">
        <xsl:attribute name="onselectstart">return false;</xsl:attribute>
        <xsl:attribute name="ondragstart">return false;</xsl:attribute>
        <xsl:call-template name="LinkPage">
         <xsl:with-param name="Node" select="//Root"/>
         <xsl:with-param name="ParentName">Root</xsl:with-param>
        </xsl:call-template>
       </body>
      </html>
    </xsl:template>
    <!-- 递归加载所有菜单 -->
    <xsl:template name="LinkPage">
      <xsl:param name="Node"/>
      <xsl:param name="ParentName"/>
      <table width="90%" border="0" cellspacing="0" cellpadding="0">
       <xsl:for-each select="$Node/Item">
        <xsl:variable name="ChildrenID">
         <xsl:value-of select="$ParentName"/>_<xsl:number value="position()"/>
        </xsl:variable>
        <tr>
         <td>
          <table width="50" border="0" cellspacing="0" cellpadding="0">
           <xsl:choose>
            <!-- 类别菜单下还有子菜单 -->
            <xsl:when test="count(./Item/Text) != 0">
             <!-- 类别菜单 -->
             <xsl:call-template name="ParentLinkPage">
              <xsl:with-param name="Node" select="."/>
              <xsl:with-param name="ChildrenID" select="$ChildrenID"/>
             </xsl:call-template>
             <!-- 列出类别菜单下的子菜单(递归) -->
             <tr style="display:none">
              <xsl:attribute name="id"><xsl:value-of select="$ChildrenID"/></xsl:attribute>
              <td/>
              <td>
               <xsl:call-template name="LinkPage">
                <xsl:with-param name="Node" select="."/>
                <xsl:with-param name="ParentName" select="$ChildrenID"/>
               </xsl:call-template>
              </td>
             </tr>
            </xsl:when>
            <!-- 类别菜单下没有子菜单,直接显示链接菜单 -->
            <xsl:otherwise>
             <xsl:call-template name="ChildLinkPage">
              <xsl:with-param name="Node" select="."/>
             </xsl:call-template>
            </xsl:otherwise>
           </xsl:choose>
          </table>
         </td>
        </tr>
       </xsl:for-each>
      </table>
    </xsl:template>
    <!-- 显示指定的一个类别菜单 -->
    <xsl:template name="ParentLinkPage">
      <xsl:param name="Node"/>
      <xsl:param name="ChildrenID"/>
      <xsl:variable name="ImgID"><xsl:value-of select="$ChildrenID"/>_Img</xsl:variable>
      <tr>
       <td width="10">
        <img src="image/c.gif" style="CURSOR: hand;" border="0">
         <xsl:attribute name="id"><xsl:value-of select="$ImgID"/></xsl:attribute>
         <xsl:attribute name="onclick">javascript: OppNode(<xsl:value-of select="$ImgID"/>,<xsl:value-of select="$ChildrenID"/>)</xsl:attribute>
        </img>
        <xsl:text> </xsl:text>
       </td>
       <td width="50" nowrap="nowrap">
        <table width="100%" border="0" cellspacing="0" cellpadding="2">
         <xsl:attribute name="class">Menu_Blur</xsl:attribute>
         <xsl:attribute name="onmouseover">javascript: this.className="Menu_Hover"</xsl:attribute>
         <xsl:attribute name="onmouseout">javascript: this.className="Menu_Blur"</xsl:attribute>
         <tr>
          <td nowrap="nowrap">
           <a>
            <xsl:attribute name="href"><xsl:value-of select="$Node/URL"/></xsl:attribute>
            <xsl:attribute name="onclick">javascript: OppNode(<xsl:value-of select="$ImgID"/>,<xsl:value-of select="$ChildrenID"/>);return false;</xsl:attribute>
            <xsl:value-of select="$Node/Text"/>
           </a>
          </td>
         </tr>
        </table>
       </td>
      </tr>
    </xsl:template>
    <!-- 显示指定的一个页面链接菜单 -->
    <xsl:template name="ChildLinkPage">
      <xsl:param name="Node"/>
      <tr>
       <td width="10">
        <a>
         <xsl:attribute name="href"><xsl:value-of select="$Node/URL"/></xsl:attribute>
         <img src="image/file.gif" border="0"/>
        </a>
        <xsl:text> </xsl:text>
       </td>
       <td width="50" nowrap="nowrap">
        <table width="100%" border="0" cellspacing="0" cellpadding="2">
         <xsl:attribute name="class">Menu_Blur</xsl:attribute>
         <xsl:attribute name="onmouseover">javascript: this.className="Menu_Hover"</xsl:attribute>
         <xsl:attribute name="onmouseout">javascript: this.className="Menu_Blur"</xsl:attribute>
         <tr>
          <td nowrap="nowrap">
           <a>
            <xsl:attribute name="href"><xsl:value-of select="$Node/URL"/></xsl:attribute>
            <xsl:value-of select="$Node/Text"/>
           </a>
          </td>
         </tr>
        </table>
       </td>
      </tr>
    </xsl:template>
    </xsl:stylesheet>


    navigater.xml
    <?xml version="1.0" encoding="GB2312"?>
    <?xml-stylesheet type="text/xsl" href="navigater.xsl"?>
    <!-- 无限深度菜单 -->
    <!--
    如果使用本代码请保留以下版权信息.
    本代码由Forlan编写, Soft@benheco.com
    -->
    <Root>
    <Item>
    <Text>父菜单(1)</Text>
    <URL>#</URL>

      <Item>
       <Text>子菜单的子菜单</Text>
       <URL>http://www.benheco.com/soft/</URL>
      </Item>
    </Item>

    <Item>
    <Text>父菜单(1)</Text>
    <URL>#</URL>

      <Item>
       <Text>子菜单的子菜单</Text>
       <URL>http://www.benheco.com/soft/</URL>
      </Item>
    </Item>


    </Root>

    我想在点下面的父菜单(1)时,让上面的父菜单(1)的子菜单自动收缩回去,我应该怎么去处理?请高手指点下,急用!先谢了!!!


       收藏   分享  
    顶(0)
      




    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2006/9/12 11:01:00
     
     GoogleAdSense
      
      
      等级:大一新生
      文章:1
      积分:50
      门派:无门无派
      院校:未填写
      注册:2007-01-01
    给Google AdSense发送一个短消息 把Google AdSense加入好友 查看Google AdSense的个人资料 搜索Google AdSense在『 XML源码及示例(仅原创和转载) 』的所有贴子 访问Google AdSense的主页 引用回复这个贴子 回复这个贴子 查看Google AdSense的博客广告
    2024/4/30 15:28:11

    本主题贴数1,分页: [1]

    管理选项修改tag | 锁定 | 解锁 | 提升 | 删除 | 移动 | 固顶 | 总固顶 | 奖励 | 惩罚 | 发布公告
    W3C Contributing Supporter! W 3 C h i n a ( since 2003 ) 旗 下 站 点
    苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
    62.500ms