刷新不變化的樹形菜單

<!--Modify by visc.cn for cbiw.com.cn 2007-03-19-->
<!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" />
<title>刷新不變化樹形菜單 - 未寺客JS</title>
<style type="text/css">
body,td,th {font-size: 14px;}
.leftmenu1 {font-weight: bold; cursor: hand; padding-top: 4px; height: 29px; text-align: left;}
.leftmenu2 {PADDING-LEFT:15px; height: 21px;text-align: left;}
div{ margin-top:90px; width:100%; text-align:center; }
</style>
</head>
<body>
<div>
<script language="JavaScript" type="text/javascript">
function Show(id,i_id){
        var on_img="http://www.cbiw.com.cn/member/pic/ass04.gif";//打開時圖片
        var off_img="http://www.cbiw.com.cn/member/pic/ass03.gif";//隱藏時圖片
        var obj=document.getElementById('c_'+id);
        if(obj.style.display=="none"){
                obj.style.display="";
        i_id.src=on_img;
        //將子菜單Id放入Cookies
        var curShow = readCookie('curShow');
        if(curShow!='')
        {
          var arr_curShow = curShow.split(',');
          var found = false;
          for(i=0;i<arr_curShow.length-1;i++)
          {
            if(arr_curShow[i].toString()==id) {found=true;}
          }
          if(!found){writeCookie('curShow',curShow+','+id,12)}
        }
        else {
          writeCookie('curShow',id,12)
        }
        //將子菜單Id放入Cookies End
        }else{
                obj.style.display="none";
        i_id.src=off_img;
        //將子菜單Id從Cookies中移除
        var curShow = readCookie('curShow');
        if(curShow!='')
        {
          var arr_curShow = curShow.split(',');
          for(i=0;i<arr_curShow.length;i++)
          {
            if(arr_curShow[i].toString()==id) {arr_curShow=arr_curShow.del(i--);}
          }
          curShow = arr_curShow.join(',');
          //alert(curShow);
          writeCookie('curShow',curShow,12)
        }
        //將子菜單Id從Cookies中移除 End
        }

}

function readCookie(name)

{

  var cookieValue = "";

  var search = name + "=";

  if(document.cookie.length > 0)

  {

    offset = document.cookie.indexOf(search);

    if (offset != -1)

    {

      offset += search.length;

      end = document.cookie.indexOf(";", offset);

      if (end == -1) end = document.cookie.length;

      cookieValue = unescape(document.cookie.substring(offset, end))

    }

  }

  return cookieValue;

}

function writeCookie(name, value, hours)

{

  var expire = "";

  if(hours != null)

  {

    expire = new Date((new Date()).getTime() + hours * 3600000);

    expire = "; expires=" + expire.toGMTString();

  }

  document.cookie = name + "=" + escape(value) + expire;

}
Array.prototype.del=function(n) {  //n表示第幾項,從0開始算起。
//prototype爲對象原型,注意這裏爲對象增加自定義方法的方法。
  if(n<0)  //如果n<0,則不進行任何操作。
    return this;
  else
    return this.slice(0,n).concat(this.slice(n+1,this.length));
}


window.onload = function a()
{
  var curShow = readCookie('curShow');
  var totalShow = 5;  //自己修改一共有多少個二級分類
  if(curShow!=''&&curShow!=null)
  {
    for(i=1;i<=totalShow;i++)
    {
      document.getElementById('c_'+i).display="none";
    }
    var arr_curShow;
    arr_curShow = curShow.split(',');
    for(i=0;i<=arr_curShow.length-1;i++)
    {
      if(arr_curShow[i]!=''){document.getElementById('c_'+arr_curShow[i]).style.display="";}
    }

  }
}
</script>
<table width="10%" border="0" align="center" cellpadding="0" cellspacing="0">

<tbody>
  <tr>
    <td class="leftmenu1"> <a style="cursor: pointer" οnclick="Show(1,img1)"><img src="http://www.cbiw.com.cn/member/pic/ass03.gif" width="16" height="16" align="absmiddle" id="img1"/><span class="ft_white"> 個人資料</span></a></td></tr>
</tbody>
<tbody id="c_1" style="display: none">
<tr>
  <td class="leftmenu2"><img src="http://www.cbiw.com.cn/member/pic/ass06.gif" width="9" height="9" /> <a href="#">基本信息</a></td></tr>
<tr>
  <td class="leftmenu2"><img src="http://www.cbiw.com.cn/member/pic/ass06.gif" width="9" height="9" /> <a href="#">修改密碼</a></td></tr>
</tbody>

<tbody>
  <tr>
    <td class="leftmenu1"> <a style="cursor: pointer" οnclick="Show(2,img2)"><img src="http://www.cbiw.com.cn/member/pic/ass03.gif" width="16" height="16" align="absmiddle" id="img2"/><span class="ft_white"> 我的簡歷</span></a></td></tr>
</tbody>
<tbody id="c_2" style="display: none">
<tr>
  <td class="leftmenu2" ><img src="http://www.cbiw.com.cn/member/pic/ass06.gif" width="9" height="9" /> <a href="#">求職簡歷</a></td></tr>
<tr>
  <td class="leftmenu2" ><img src="http://www.cbiw.com.cn/member/pic/ass06.gif" width="9" height="9" /> <a href="#">求職意向</a></td></tr>
<tr>
  <td class="leftmenu2" ><img src="http://www.cbiw.com.cn/member/pic/ass06.gif" width="9" height="9" /> <a href="#">上傳照片</a></td></tr>
<tr>
  <td class="leftmenu2" ><img src="http://www.cbiw.com.cn/member/pic/ass06.gif" width="9" height="9" /> <a href="#">簡歷預覽</a></td></tr>
</tbody>

<tbody>
  <tr>
    <td class="leftmenu1"> <a style="cursor: pointer" οnclick="Show(3,img3)"><img src="http://www.cbiw.com.cn/member/pic/ass03.gif" width="16" height="16" align="absmiddle" id="img3"/><span class="ft_white"> 職位搜索</span></a></td></tr>
</tbody>
<tbody id="c_3" style="display: none">
<tr>
  <td class="leftmenu2" ><img src="http://www.cbiw.com.cn/member/pic/ass06.gif" width="9" height="9" /> <a href="#">快速搜索</a></td></tr>
</tbody>

<tbody>
  <tr>
    <td class="leftmenu1"> <a style="cursor: pointer" οnclick="Show(4,img4)"><img src="http://www.cbiw.com.cn/member/pic/ass03.gif" width="16" height="16" align="absmiddle" id="img4"/><span class="ft_white"> 應聘管理</span></a></td></tr>
</tbody>
<tbody id="c_4" style="display: none">
<tr>
  <td class="leftmenu2" ><img src="http://www.cbiw.com.cn/member/pic/ass06.gif" width="9" height="9" /> <a href="#">應聘記錄</a></td></tr>
<tr>
  <td class="leftmenu2" ><img src="http://www.cbiw.com.cn/member/pic/ass06.gif" width="9" height="9" /> <a href="#">企業邀請</a></td></tr>
<tr>
  <td class="leftmenu2" ><img src="http://www.cbiw.com.cn/member/pic/ass06.gif" width="9" height="9" /> <a href="#">收藏職位</a></td></tr>
</tbody>

<tbody>
  <tr>
    <td class="leftmenu1"> <a style="cursor: pointer" οnclick="Show(5,img5)"><img src="http://www.cbiw.com.cn/member/pic/ass03.gif" width="16" height="16" align="absmiddle" id="img5"/><span class="ft_white"> 我的知識</span></a></td></tr>
</tbody>
<tbody id="c_5" style="display: none">
<tr>
  <td class="leftmenu2" ><img src="http://www.cbiw.com.cn/member/pic/ass06.gif" width="9" height="9" /> <a href="#">我要提問</a></td></tr>
<tr>
  <td class="leftmenu2" ><img src="http://www.cbiw.com.cn/member/pic/ass06.gif" width="9" height="9" /> <a href="#">我要回答</a></td></tr>
<tr>
  <td class="leftmenu2" ><img src="http://www.cbiw.com.cn/member/pic/ass06.gif" width="9" height="9" /> <a href="#">發問記錄</a></td></tr>
<tr>
  <td class="leftmenu2" ><img src="http://www.cbiw.com.cn/member/pic/ass06.gif" width="9" height="9" /> <a href="#">回答記錄</a></td></tr>
<tr>
  <td class="leftmenu2" ><img src="http://www.cbiw.com.cn/member/pic/ass06.gif" width="9" height="9" /> <a href="http://www.visc.cn" target="_blank" title="未寺客(visc.cn) - 做個廣告,嘿嘿">分數記錄</a></td></tr>
</tbody>
</table>
</div>
</body>
</html> 

發佈了166 篇原創文章 · 獲贊 3 · 訪問量 40萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章