12、非常酷的 导航代码

12、非常酷的 导航代码

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=gb2312">

<title>有声有色 2004 - 特效名称:WinXP渐显声效菜单</title>

</head>

 

<body>

 

 

<SCRIPT language="JavaScript">

<!-- Begin

document.write('<style><!--');

document.write('    .menutableT    {border-left: 5 solid #FF0000; border-right: 5 solid #307CE8;border-top: 1 solid #94BCF3; border-bottom: 1 solid #307CE8; font-size: 12px; background-color: #FFFFFF;}');

document.write('    .menutable{position: absolute; z-index: 100; border-left: 5 solid #FF0000; border-right: 1 solid #307CE8; border-top: 1 solid #94BCF3; border-bottom: 1 solid #307CE8; font-size: 12px; background-color: #FFFFFF;}');

document.write('    .menutrin{background-color: #1A71E6; color: #000000; cursor: default;}');

document.write('    .menutrout{color: #000000; cursor: default;}      ');

document.write('    .menutd0{text-align: center; width: 28; height: 25;}');

document.write('    .menutd1{text-align: right;    width: 50; font-family: Webdings;}');

document.write('    .linktd1{width: 46;}      ');

document.write('    .menutd2{width: 4;}');

document.write('    .menuhr{border: 1 inset #307CE8;}');

document.write('    .indentWord{padding-left: 2px;}');

document.write('--></style>');

document.write('<bgsound src="" loop="0" id="theBS"> ');

var SubMenuList = new Array();

var NowSubMenu = "";

var mouseCanSound = true;

var menuSpeed     =  50; 

var alphaStep     =  30;

function TopMenu(objName,L,T)

{

       this.id     = "Menu_"+objName;

       this.obj    = objName;

       this.length  = 0;

       this.L       = L

       this.T       = T

       this.addTopMenu = addTopMenu;

       this.addTopLink = addTopLink;

       this.returnAll  = returnAll

       document.body.insertAdjacentHTML('afterBegin','<div id="temp_'+this.id+'" style="display: none;"><table id="'+this.id+'" border="0" cellspacing="0" cellpadding="0" class="menutableT" ><tr></tr></table></div>');

}

function returnAll(str)

{

       var obj = eval("temp_"+this.id);

       str = eval(str)

       var tempstr = obj.innerHTML

       obj.outerHTML = "";

       str.insertAdjacentHTML('beforeEnd',tempstr)

}

function SubMenu(objName,objID)

{

       this.obj = objName;

       this.id  = objID;

       this.addMenu = addMenu;

       this.addLink = addLink;

       this.addHR   = addHR;

       this.length  = 0;

}

function addTopMenu(word,icon,title)

{

       var subID    = this.id + "_" + this.length;

       var subObj  = this.obj+"["+this.length+"]";

       var oldID   = this.id;

       eval(subObj+"= new SubMenu('"+subObj+"','"+subID+"')");

    makeTopMenu(subID,oldID,word,icon,title);

    this.length++;

}

function addTopLink(word,icon,url,target,title)

{

       var subID    = this.id + "_" + this.length;

       var oldID  = this.id;

       makeTopLink(subID,oldID,word,icon,url,target,title);

       this.length++;

}

function makeTopMenu(subID,oldID,word,icon,thetitle)

{

    icon='';

       if(!thetitle||thetitle==""){thetitle = '';}

       var Oobj = document.getElementById(oldID);

       var TempTableStr = '<table border="0" cellspacing="0" cellpadding="0" style="font-size: 12px">'

                                    + '<tr class="menutrout" id="tr'+subID+'" onmousedown="TMtrClick(this)" onmouseover="MtrOver(this,1);this.MH=false" title="'+thetitle+'" onmouseup="event.cancelBubble=true">'

                                    + '<td class="menutd0">'+icon+'</td>'

                                    + '<td><nobr class=indentWord>'+word+'</nobr></td>'

                                    + '<td class="menutd2"> </td>'

                                    + '</tr></table>'

       Oobj.rows(0).insertCell().innerHTML = TempTableStr

       document.body.insertAdjacentHTML('beforeEnd','<table id="'+subID+'" border="0" cellspacing="0" cellpadding="0" style="top: 0; left: 0; visibility: hidden; filter:Alpha(Opacity=0);" class="menutable" ></table>');

}

function makeTopLink(subID,oldID,word,icon,url,target,thetitle)

{

       var thelink = '';

    icon='';

       if(!thetitle||thetitle==""){thetitle = '';}

       if(url&&url!=""){thelink += '<a href="'+url+'" ';

              if(target&&target!=""){thelink += '  '; thelink += 'target="'+target+'" '}

              thelink += '></a>';}

       var Oobj = document.getElementById(oldID);

       var TempTableStr = '<table border="0" cellspacing="0" cellpadding="0" style="font-size: 12px">'

                                    + '<tr class="menutrout" id="tr'+subID+'" onmouseout="LtrOut(this,1)" onmouseover="LtrOver(this,1)" onclick="MtrClick(this,1)" title="'+thetitle+'">'

                                    + '<td class="menutd0">'+icon+'</td>'

                                    + '<td>'+thelink+'<nobr class=indentWord>'+word+'</nobr></td>'

                                    + '<td class="menutd2"> </td>'

                                    + '</tr></table>'

       Oobj.rows(0).insertCell().innerHTML = TempTableStr             

}

function addMenu(word,icon,url,target,title)

{

       var subID    = this.id + "_" + this.length;

       var subObj  = this.obj+"["+this.length+"]";

       var oldID   = this.id;

       eval(subObj+"= new SubMenu('"+subObj+"','"+subID+"')");

       makeMenu(subID,oldID,word,icon,url,target,title);

       this.length++;

}

function addLink(word,icon,url,target,title)

{

       var subID    = this.id + "_" + this.length;

       var oldID  = this.id;

    makeLink(subID,oldID,word,icon,url,target,title);

       this.length++;

}

function addHR()

{

       var oldID = this.id;

       var Oobj = document.getElementById(oldID);

       Oobj.insertRow();

       Oobj.rows(Oobj.rows.length-1).insertCell();

       with(Oobj.rows(Oobj.rows.length-1))

       {

              cells(0).colSpan= 4;

              cells(0).insertAdjacentHTML('beforeEnd','<hr class="menuhr" size="1" width="95%">');             

       }    

}

function makeMenu(subID,oldID,word,icon,url,target,thetitle)

{

       var thelink = '';

       icon = '';

       if(!thetitle||thetitle==""){thetitle = '';}

       if(url&&url!=""){thelink += '<a href="'+url+'" ';

       if(target&&target!=""){ thelink += '  ';thelink += 'target="'+target+'" '}

              thelink += '></a>';}

       var Oobj = document.getElementById(oldID);

       Oobj.insertRow();

       with(Oobj.rows(Oobj.rows.length-1))

       {

              id                  = "tr"+subID;

              className      = "menutrout";

              title       = thetitle;

       }

       eventObj = "tr"+subID;

       eval(eventObj+'.attachEvent("onmouseover",MtrOver('+eventObj+'))');    

       eval(eventObj+'.attachEvent("onclick",MtrClick('+eventObj+'))');     

       var trObj = eval(eventObj);

       for(i=0;i<4;i++){trObj.insertCell();}

       with(Oobj.rows(Oobj.rows.length-1))

       {

              cells(0).className = "menutd0";

              cells(0).innerHTML = icon;

              cells(1).innerHTML = thelink+'<nobr class=indentWord>'+word+'</nobr>';

              cells(1).calssName = "indentWord"

              cells(2).className = "menutd1";

              cells(2).innerHTML = "4";

              cells(3).className = "menutd2";

              cells(3).innerText = " ";

       }    

       document.body.insertAdjacentHTML('beforeEnd','<table id="'+subID+'" border="0" cellspacing="0" cellpadding="0" style="top: 0; left: 0; visibility: hidden; filter:Alpha(Opacity=0);" class="menutable"></table>');

       }

function makeLink(subID,oldID,word,icon,url,target,thetitle)

{

       var thelink = '';

       icon = '';

       if(!thetitle||thetitle==""){thetitle = '';}

       if(url&&url!=""){thelink += '<a href="'+url+'" ';

              if(target&&target!=""){ thelink += '  '; thelink += 'target="'+target+'" '}

              thelink += '></a>';}

       var Oobj = document.getElementById(oldID);

       Oobj.insertRow();

       with(Oobj.rows(Oobj.rows.length-1)){id                  = "tr"+subID;className = "menutrout";title       = thetitle;}

       eventObj = "tr"+subID;

       eval(eventObj+'.attachEvent("onmouseover",LtrOver('+eventObj+'))');     

       eval(eventObj+'.attachEvent("onmouseout",LtrOut('+eventObj+'))');        

       eval(eventObj+'.attachEvent("onclick",MtrClick('+eventObj+'))');     

       var trObj = eval(eventObj);

       for(i=0;i<4;i++){trObj.insertCell();}

       with(Oobj.rows(Oobj.rows.length-1)){

              cells(0).className = "menutd0";

              cells(0).innerHTML = icon;

              cells(1).innerHTML = thelink+'<nobr class=indentWord>'+word+'</nobr>';

              cells(2).className = "linktd1";

              cells(2).innerText = " ";

              cells(3).className = "menutd2";

              cells(3).innerText = " ";

              }    

}

function MtrOver(obj,isTop)

{

if(isTop)

{

              var sonid = obj.id.substring(2,obj.id.length);

              var topobj = obj.parentElement.parentElement;

              NowSubMenu = topobj.id;

              if(obj.className=="menutrout"){mouseWave();}             

              HideMenu(1);       

              SubMenuList[returnIndex(NowSubMenu)] = NowSubMenu;

              if(isTop){ShowTheMenu(sonid,100)}

              else{ShowTheMenu(sonid,MPreturn(sonid))       }           

              SubMenuList[returnIndex(obj.id)] = sonid;

              if(topobj.oldTR){ eval(topobj.oldTR+'.className = "menutrout"'); }

              obj.className = "menutrin";

              topobj.oldTR = obj.id;

}

else

{

       return sub_over;

       function sub_over()

       {

              var sonid = obj.id.substring(2,obj.id.length);

              var topobj = obj.parentElement.parentElement;

              NowSubMenu = topobj.id;

              if(obj.className=="menutrout"){ mouseWave();}            

              HideMenu(1);       

              SubMenuList[returnIndex(NowSubMenu)] = NowSubMenu;

              if(isTop){ShowTheMenu(sonid,100)}

              else{ShowTheMenu(sonid,MPreturn(sonid))}            

              SubMenuList[returnIndex(obj.id)] = sonid;

           if(topobj.oldTR){eval(topobj.oldTR+'.className = "menutrout"');}

              obj.className = "menutrin";

              topobj.oldTR = obj.id;

       }

}    

}

function LtrOver(obj,isTop)

{

if(isTop)

{

              var topobj = obj.parentElement.parentElement;

              NowSubMenu = topobj.id;   

              HideMenu(1);

              SubMenuList[returnIndex(NowSubMenu)] = NowSubMenu;

              if(topobj.oldTR){eval(topobj.oldTR+'.className = "menutrout"');}

              obj.className = "menutrin";

              topobj.oldTR = obj.id;

}

else

{

       return sub_over;

       function sub_over()

       {

              var topobj = obj.parentElement.parentElement;

              NowSubMenu = topobj.id;

              HideMenu(1);

              SubMenuList[returnIndex(NowSubMenu)] = NowSubMenu;

              if(topobj.oldTR){eval(topobj.oldTR+'.className = "menutrout"');}

              obj.className = "menutrin";

              topobj.oldTR = obj.id;

       }

}    

}

function LtrOut(obj,isTop)

{

  if(isTop){var topobj = obj.parentElement.parentElement; obj.className = "menutrout"; topobj.oldTR = false; }

  else{return sub_out;function sub_out(){   var topobj = obj.parentElement.parentElement; obj.className = "menutrout"; topobj.oldTR = false; }}      

}

function MtrClick(obj,isTop)

{

if(isTop){if(obj.cells(1).all.tags("A").length>0){obj.cells(1).all.tags("A")(0).click();}}

else{return sub_click;function sub_click(){  if(obj.cells(1).all.tags("A").length>0)   {obj.cells(1).all.tags("A")(0).click();}}}     

}

function TMtrClick(obj)

{

       if(obj.MH){    MtrOver(obj,1); obj.MH = false;}

       else{document.onmouseup(); obj.MH = true;}

}

function returnIndex(str)

{

       return (str.split("_").length-3)

}

function ShowTheMenu(obj,num)

{

       var topobj = eval(obj.substring(0,obj.length-2));

       var SrcObj  = eval(topobj.id.split("_")[1])

       var ML      = 0

       if(SrcObj.L){ML                  += eval(SrcObj.L)}             

       var MT      = 0

       if(SrcObj.T){MT                  += eval(SrcObj.T)}             

       var trobj  = eval("tr"+obj);

       var obj = eval(obj);

       var TheTDLeft = trobj.parentElement.parentElement.parentElement.offsetLeft;      

       if(num==0){with(obj.style){pixelLeft = topobj.style.pixelLeft +topobj.offsetWidth;pixelTop  = topobj.style.pixelTop + trobj.offsetTop;}}

       if(num==1){with(obj.style){pixelLeft = topobj.style.pixelLeft + topobj.offsetWidth;pixelTop  = topobj.style.pixelTop  + trobj.offsetTop + trobj.offsetHeight - obj.offsetHeight;}}

       if(num==2){with(obj.style){pixelLeft = topobj.style.pixelLeft -  obj.offsetWidth;pixelTop  = topobj.style.pixelTop + trobj.offsetTop;}}

       if(num==3){with(obj.style){pixelLeft = topobj.style.pixelLeft -  obj.offsetWidth;pixelTop  = topobj.style.pixelTop  + trobj.offsetTop + trobj.offsetHeight - obj.offsetHeight;}}

       if(num==100){with(obj.style){pixelLeft = document.body.scrollLeft + topobj.offsetLeft + TheTDLeft + ML;pixelTop  = document.body.scrollTop + topobj.offsetTop + topobj.offsetHeight + MT;}}

       obj.style.visibility  = "visible";  

       if(obj.alphaing){clearInterval(obj.alphaing);}

       obj.alphaing = setInterval("menu_alpha_up("+obj.id+","+alphaStep+")",menuSpeed);

}

function HideMenu(num)

{

       var thenowMenu = "";

       var obj = null;

       if(num==1){thenowMenu = NowSubMenu}

       for(i=SubMenuList.length-1;i>=0;i--)

       {

              if(SubMenuList[i]&&SubMenuList[i]!=thenowMenu){obj = eval(SubMenuList[i]);

                     if(obj.alphaing){clearInterval(obj.alphaing);}     

                 obj.alphaing = setInterval("menu_alpha_down("+obj.id+","+alphaStep+")",menuSpeed);

                     obj.style.visibility = "hidden";

                     eval("tr"+SubMenuList[i]).className = "menutrout";

                     SubMenuList[i] = null; 

              }

              else

              {

                     if(SubMenuList[i]==thenowMenu){return;}

              }

       }

       NowSubMenu = "";

}

function MPreturn(obj)

{

       var topobj = eval(obj.substring(0,obj.length-2));

       var trobj  = eval("tr"+obj);

       var x = topobj.style.pixelLeft + topobj.offsetWidth;

       var y = topobj.style.pixelTop  + trobj.offsetTop;

       obj = eval(obj);

       var judgerY =  obj.offsetHeight + y;

       var judgerX =  obj.offsetWidth  + x;

       var py = 0;

       var px = 0;

       if(judgerY>=document.body.clientHeight){py = 1;}

       if(judgerX>= document.body.clientWidth){px = 2;}

       return (px+py);

}

function mouseWave()

{

       if(mouseCanSound){theBS.src= "cbsound.wav";}      

}

function menu_alpha_down(obj,num)

{

              var obj = eval(obj);

              if(obj.filters.Alpha.Opacity > 0 ){obj.filters.Alpha.Opacity += -num;}    

              else{clearInterval(obj.alphaing);obj.filters.Alpha.Opacity = 0;   obj.alphaing = false;obj.style.visibility = "hidden";}  

}

function menu_alpha_up(obj,num)

{

              var obj = eval(obj);

              if(obj.filters.Alpha.Opacity<100)

                     obj.filters.Alpha.Opacity += num;

              else{clearInterval(obj.alphaing);obj.filters.Alpha.Opacity = 100;obj.alphaing = false;}   

}

function document.onmouseup()

{

       HideMenu();

}

//  End -->

</SCRIPT>

<SCRIPT language="JavaScript">

<!-- Begin

var TM = new TopMenu("TM")

TM.addTopMenu("fdgdfg",0)

       TM[0].addLink("dfgdfgdfg",0,"http://")

       TM[0].addLink("dfgdfgdfgdf",0,"http://")

       TM[0].addLink("fghdfhdfgdf",0,"http://")

       TM[0].addLink("fdgdfgdfg",0,"http://")

       TM[0].addLink("fdgdfgdf",0,"http://")

 

TM.addTopMenu("cvbcvbncvn",0)

       TM[1].addLink("cvbcvbncncv",0,"http://ghjghj.cc")

 

TM.addTopMenu("cvbcvbn",0)

       TM[2].addLink("ncvcvncvn",0,"http://cvbcvncv")

 

TM.addTopMenu("vbnvbn",0)

       TM[3].addLink("cvbcvn",0,"http://")

 

 

TM.returnAll("document.body")

//  End -->

</SCRIPT>

 

 

 

</body>

 

</html>

 

Write a comment

Comments: 1
  • #1

    csr04 (Tuesday, 01 September 2009 13:50)

    test