`
superyang
  • 浏览: 22228 次
  • 性别: Icon_minigender_2
  • 来自: 广州
社区版块
存档分类
最新评论
阅读更多


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>网页教学网无限级树型菜单演示</title>
<script type="text/javascript">
//more javascript from http://www.webjx.com
var temp, temp2, cookieArray, cookieArray2, cookieCount;

function initiate(){

  cookieCount=0;

  if(document.cookie){

    cookieArray=document.cookie.split(";");
    cookieArray2=new Array();

    for(i in cookieArray){
      cookieArray2[cookieArray[i].split("=")[0].replace(/ /g,"")]=cookieArray[i].split("=")[1].replace(/ /g,"");
    }

  }

  cookieArray=(document.cookie.indexOf("state=")>=0)?cookieArray2["state"].split(","):new Array();

  temp=document.getElementById("containerul");

  for(var o=0;o<temp.getElementsByTagName("li").length;o++){

    if(temp.getElementsByTagName("li")[o].getElementsByTagName("ul").length>0){

      temp2 = document.createElement("span");
      temp2.className = "symbols";
      temp2.style.backgroundImage = (cookieArray.length>0)?((cookieArray[cookieCount]=="true")?"url(tree/minus.png)":"url(tree/plus.png)"):"url(tree/plus.png)";
      temp2.onclick=function(){
        showhide(this.parentNode);
        writeCookie();
      }

      temp.getElementsByTagName("li")[o].insertBefore(temp2,temp.getElementsByTagName("li")[o].firstChild)

      temp.getElementsByTagName("li")[o].getElementsByTagName("ul")[0].style.display = "none";

      if(cookieArray[cookieCount]=="true"){
        showhide(temp.getElementsByTagName("li")[o]);
      }

      cookieCount++;

    }
    else{

      temp2 = document.createElement("span");
      temp2.className = "symbols";
      temp2.style.backgroundImage = "url(tree/page.png)";

      temp.getElementsByTagName("li")[o].insertBefore(temp2,temp.getElementsByTagName("li")[o].firstChild);

    }

  }

}



function showhide(el){

  el.getElementsByTagName("ul")[0].style.display=(el.getElementsByTagName("ul")[0].style.display=="block")?"none":"block";

  el.getElementsByTagName("span")[0].style.backgroundImage=(el.getElementsByTagName("ul")[0].style.display=="block")?"url(tree/minus.png)":"url(tree/plus.png)";

}



function writeCookie(){ // Runs through the menu and puts the "states" of each nested list into an array, the array is then joined together and assigned to a cookie.

  cookieArray=new Array()

  for(var q=0;q<temp.getElementsByTagName("li").length;q++){

    if(temp.getElementsByTagName("li")[q].childNodes.length>0){
      if(temp.getElementsByTagName("li")[q].childNodes[0].nodeName=="SPAN" && temp.getElementsByTagName("li")[q].getElementsByTagName("ul").length>0){

        cookieArray[cookieArray.length]=(temp.getElementsByTagName("li")[q].getElementsByTagName("ul")[0].style.display=="block");

      }
    }

  }

  document.cookie="state="+cookieArray.join(",")+";expires="+new Date(new Date().getTime() + 365*24*60*60*1000).toGMTString();

}

</script>

<style type="text/css"><!--

#containerul, #containerul ul{
  text-align:left;
  margin:0; /* Removes browser default margins applied to the lists. */
  padding:0; /* Removes browser default padding applied to the lists. */
}

#containerul li{
  margin:0 0 0 30px; /* A left margin to indent the list items and give the menu a sense of structure. */
  padding:0; /* Removes browser default padding applied to the list items. */
  list-style-type:none; /* Removes the bullet point that usually goes next to each item in a list. */
}

#containerul .symbols{ /* Various styles to position the symbols next to the items in the menu. */
  float:left;
  width:12px;
  height:1em;
  background-position:0 50%;
  background-repeat:no-repeat;
}

--></style>
</head>

<body>
<ul id="containerul">
  <li> 网页教学网
    <ul>
      <li> <a href="http://www.webjx.com/htmldata/sort/2.html">建站指南</a>
      </li>
      <li>
        <a href="http://www.webjx.com/htmldata/sort/3.html">网页制作</a>
      </li>
      <li>
        <a href="http://www.webjx.com/htmldata/sort/4.html">动画制作</a>
      </li>
    </ul>
  </li>
 
  <li> 网络编程
    <ul>
      <li>
        <a href="http://www.webjx.com/htmldata/sort/24.html">Asp.net</a>
      </li>
      <li>
        <a href="http://www.webjx.com/htmldata/sort/25.html">Asp</a>
        <ul>
          <li>
            <a href="http://www.webjx.com/htmldata/sort/26.html">PHP</a>
          </li>
          <li>
            <a href="http://www.webjx.com/htmldata/sort/28.html">数据库</a>
          </li>
          <li>
            <a href="http://www.webjx.com/htmldata/sort/29.html">CGI</a>
          </li>
   <li>
            <a href="http://www.webjx.com/htmldata/sort/29.html">java网络编程</a>
      <ul>
          <li>
            <a href="http://www.webjx.com/htmldata/sort/26.html">jsp</a>
          </li>
          <li>
            <a href="http://www.webjx.com/htmldata/sort/28.html">j2ee</a>
          </li>
  </ul>
          </li>
        </ul>
      </li>
    </ul>
  </li>
</ul>

<p>
  <script type="text/javascript">
initiate(); // This must be placed immediately after the menu in order to format it properly.
</script>
</p>
<h3>树形菜单</h3>
<p>说明:一个很容易制作树形菜单,你可以无限级的添加下级菜单,菜单是通过列表方式写成的 </p>
</body>
</html>

 

分享到:
评论
1 楼 shily_yuanling 2009-12-07  
你做网站的?怎么都是跟C有关系的啊东西啊!呵呵……姐姐英文不错吧!

相关推荐

    java 二叉树实现

    java二叉树实现 (简单实现,入门用) /**创建二叉树*/ public BinaryTree createTree(String treeStr); /**寻找结点*/ public BinaryTree findNode(BinaryTree ... public void disPlayTree(BinaryTree tree);

    NPPJSONViewer1.40.zip

    issue-73 Display tree for Array of Object issue-80 use line ending setting from editor Relaxed parsing. Supports trailling commas, comments(only parsing), NaN and infinity JS literals.

    Display GitHub code in tree format.zip

    Display GitHub code in tree format.zip,类固醇上的github代码树

    二叉树数据结构课程设计

    编写函数displaytree(二叉树的根指针,数据值宽度,屏幕的宽度)输出树的直观示意图。输出的二叉树是垂直打印的,同层的节点在同一行上。 [问题描述] 假设数据宽度datawidth=2,而屏幕宽度screenwidth为64=26,假设...

    Eclipse 4 Plug-in Development by Example: Beginner's Guide

    How to display tree and table information in views What are the specific differences between the Eclipse 3.x model and the Eclipse 4.x model How and when to build user interfaces from SWT and JFace...

    树状显示二叉树和完全二叉树判断

    编写函数displaytree(二叉树的根指针,数据值宽度,屏幕的宽度)输出树的直观示意图。输出的二叉树是垂直打印的,同层的节点在同一行上。 问题描述: 假设数据宽度datawidth=2,而屏幕宽度screenwidth为64=26,假设节点...

    数据结构树的操作实验报告

    displayTree () 初始条件:存在一非空的树 操作条件:显示非空树中的所有元素的值 getString () 初始条件:存在一非空的二叉树 操作结果:返回整个字符串的数值 getChar () 初始条件:存在一非空的二叉树 操作结果:...

    dir display in the format of tree

    在linux操作系统上以树的形式显示一个目录中的文件,一个不错的小软件

    an improved illumination model for shaded display

    this tree for each pixel of the display and passes it to the shader. The shader then traverses the tree to determine the intensity of the light received by the viewer. Consideration of all of these...

    d3-org-tree:使用d3.js v5构建的高度可定制的组织树

    预设或动态更改布局orientation ,链接样式以及是否display arrows 预设svg容器的width/height和内容的边距偏移 预设变换动画的duration 在节点click上自定义回调函数, add和remove事件 演示版 正在安装 npm i d3...

    基于c#、jquery开发的treeView目录树组件

    Based on c#, jquery development treeView tree components, the biggest feature is the display of the tree node state to ajax way, saved to a user session, even if a page refresh, the tree' s display ...

    用JS实现一个TreeMenu效果分享

    类似TreeMenu控件. 不废话直接代码: 代码如下: [removed] function control() {//定义函数 if (sMenus3[removed] == “+”) {//判断展开状态 ulMenu3.style.display = “block”;//如果是“+”号 则可以展开 ...

    二叉树可视化Java语言实现(完整版,打开即可运行)

    二叉树可视化Java语言实现,包含四个字文件、BinaryNode、Show1_12、Display_Tree、TreeControl。直接可以运行,方便快捷。

    HEVC码流分析软件

    + Display Order Playback: Play/Pause/FF/FR/StepForward/StepBackward. + Decoding Order Playback: Play/Pause/FF/StepForward. I/P/B CU insight analysis, including: + mb type + intra/inter prediction ...

    自定义语法与CFG,通过hanlp和nltk的CRF语法解析算法进行语法树构建,并使用for循环进行遍历树,然后分词合并成短语

    # 说明 通过hanlp和nltk的CRF语法解析算法进行...Draw tree with Display ... [Tree('S', [Tree('N', ['我们']), Tree('VP', [Tree('V', ['尊敬']), Tree('N', ['老师'])])])] ``` # extract_nvp.py 通过hanlp和nltk

    X-window processes tree display-开源

    xps在UNIX的X窗口中动态显示Unix处理为一棵树或森林,其根在左侧,叶处理(无子级)在右侧。 每个进程的运行,Hibernate,停止等状态都可以用颜色表示。 迪

    crc.rar_CRC PLOT MATLAB_builder treeview_matlab crc_matlab treev

    It comes with new interface and an enhanced display. It uses Microsoft TreeView control to display and explore any kind of MatLab structures. The CRC ExploreStruct was designed to expose the contents...

    leetcode2-BinaryTree:LeetCodeOJ在Python中的二叉树可视化

    leetcode ...t.display() 你会得到: 1 / \ / \ / \ / \ 2 3 / \ \ / \ \ 4 5 6 / \ 7 8 测试 python -m unittest -v test LeetCode 二叉树序列化 见,点击“阅读更多关于如何在 OJ 上序列化二叉树”

    mail_git_tree-crx插件

    语言:中文 (简体) Chrome extension to display Gitlab code in tree format在gitlab中展示文件树

    用ooad的思想实现圣诞树打印

    * display trunk of tree * @author mm */ public class Trunk extends Shape{ /** * defaulted constructor */ public Trunk(){ } /** * to print trunk of tree */ public void print(){ ...

Global site tag (gtag.js) - Google Analytics