|
/* KuoMart.com__MyKuoMart , Create By ybcola(at)163.com , 2006-7-2
Last Modified 2006-7-2 , ybcola@163.com */
<!--
function Dtree(){
this.MenuGroupClose="images/treeview_close.gif"; //菜單關閉圖標
this.MenuGroupOpen="images/treeview_open.gif"; //菜單打開圖標
this.MenuItemClass=""; //菜單項樣式
this.MenuItemInfoClass=""; //菜單鏈接樣式
this.MenuItemlPad="12px";//下級菜單縮進仁值
this.DefaultGroupState=false; //菜單組裝入時默認狀態
document.write("<div id=/"treeroot/"></div>");
this.Node=document.getElementById("treeroot");
//0結點DOM對像,數組1為連接顯示,2為連接href,3為連接target,4為連接顯示前圖標
this.AddItem=function(menuinfo){
var div=creatediv();
var div1=creatediv();
var ico=[this.MenuGroupClose,this.MenuGroupOpen];
div.className=this.MenuItemClass;
div1.style.marginLeft=this.MenuItemlPad;
div1.style.display=this.DefaultGroupState?"":"none";
var Node=menuinfo[0]?menuinfo[0][1]:this.Node;
var iteminfo="";
if(menuinfo[4]) iteminfo="<img src=/""+menuinfo[4]+"/" align=/"absmiddle/">";
if(menuinfo[2]) iteminfo+=" <a href=/""+menuinfo[2]+"/" target=/""+menuinfo[3]+"/" class=/""+this.MenuItemInfoClass+"/">";
iteminfo+=menuinfo[1];
if(menuinfo[2])iteminfo+="</a>";
div.innerHTML=iteminfo;
Node.appendChild(div);
Node.appendChild(div1);
if(menuinfo[0]){
if(!menuinfo[0][0].havechild) {
var as=document.createElement("img");
as.src=ico[1];
as.align="absmiddle";
as.onclick=function(){
swapshow(Node,as,ico);
}
menuinfo[0][0].insertBefore(as,menuinfo[0][0].firstChild);
as.insertAdjacentText("afterEnd"," ");
menuinfo[0][0].havechild=true;
}
}
return [div,div1];
}
function creatediv(){
var div=document.createElement("div");
return div;
}
function swapshow(obj,ico,oo){
if(obj.style.display!=""){
obj.style.display="";
ico.src=oo[0];
}
else{
obj.style.display="none";
ico.src=oo[1];
}
}
}
-->
JavaScript技術:javascript+dom樹型菜單類,希望朋友們一起進步,轉載需保留來源!
鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。