Home > front end >  The tree navigation dTree, JS way to add navigation
The tree navigation dTree, JS way to add navigation

Time:12-18

Due to no permission to edit source files, how to add a navigation section by JS,
Such as: (14, 1, 'China merchants advertising', 'news. HTML', 'pics/edit. JPG);
No permission to edit the source file to add, only by way of JS to force to add a navigation, strives for the teachers to help write down
 


<meta HTTP - equiv="content-type" Content="text/HTML. Charset=gb2312 "/& gt;

<link rel="StyleSheet" href="https://bbs.csdn.net/topics/css/dtree.css" type="text/CSS"/& gt;

<body style="background - color: # FFFFFF; margin:0;">

D=new dTree (' d ');
D.i con={
Root: 'pics/daohang. JPG,

Folder: 'img/folder. GIF,

FolderOpen: 'img/folderOpen. GIF,

Node: 'img/page. GIF,

The empty: 'img/empty. GIF,

The line: 'img/line. GIF,

The join: 'img/join. GIF',

JoinBottom: 'img/joinBottom. GIF,

Plus: 'img/plus. GIF,

PlusBottom: 'img/plusBottom. GIF,

Minus: 'img/minus. GIF,

MinusBottom: 'img/minusBottom. GIF,

NlPlus: 'img/nolines_plus. GIF,

NlMinus: 'img/nolines_minus. GIF'

};
Da dd (0, 1, 'management menu', ', 'pics/daohang. JPG);
Da dd (1, 0, 'product management', ' 'and' pics/m_news. GIF ', 'pics/m_news. GIF);
Da dd (1, 1, 'release goods',' send. Aspx ', 'pics/send JPG);
Da dd (13, 1, 'warehouse management', 'common. Aspx', 'pics/edit. JPG);
document.write(d);

</script>


 function Node (id, pid, name, url, icon, iconOpen, open) {
this.id=id;
This. Pid=pid;
this.name=name;
Enclosing the url=url;
Enclosing url1="";
Enclosing the title="";
This. Target="mainFrame";
Enclosing target1="mainFrame";
This. (=icon;
Enclosing iconOpen=iconOpen;
Enclosing _io=open | | false;
Enclosing _is=false;
Enclosing _ls=false;
Enclosing _hc=false;
Enclosing _ai=0;
This. _p;
};
//Tree object
The function dTree (objName) {
Enclosing the config={
Target: null,
FolderLinks: true,
UseSelection: true,
UseCookies: true,
UseLines: false,//
UseIcons: true,
UseStatusText: false,
CloseSameLevel: true,
InOrder: false
}
This. (={
Root: 'pics/daohang. JPG,

Folder: 'img/folder. GIF,

FolderOpen: 'img/folderOpen. GIF,

Node: 'img/page. GIF,

The empty: 'img/empty. GIF,

The line: 'img/line. GIF,

The join: 'img/join. GIF',

JoinBottom: 'img/joinBottom. GIF,

Plus: 'img/plus. GIF,

PlusBottom: 'img/plusBottom. GIF,

Minus: 'img/minus. GIF,

MinusBottom: 'img/minusBottom. GIF,

NlPlus: 'img/nolines_plus. GIF,

NlMinus: 'img/nolines_minus. GIF'

};

This. Obj=objName;

Enclosing aNodes=[];

Enclosing aIndent=[];

This. The root=new Node (1);

Enclosing selectedNode=null;

Enclosing selectedFound=false;

This.com pleted=false;

};
DTree. Prototype. The add=function (id, pid, name, url, url1, title, target, target1, icon, iconOpen, open) {
Enclosing aNodes [this aNodes. Length]=new Node (id, pid, name, url, url1, title, target, target1, icon, iconOpen, open);
};
//Open/close all nodes
DTree. Prototype. OpenAll=function () {
Enclosing oAll (true);
};
DTree. Prototype. CloseAll=function () {
Enclosing oAll (false);
};

DTree. Prototype. ToString=function () {
Var STR='& lt; Div id="DDS" & gt; ';
If (document. GetElementById) {
If (this. Config. UseCookies) enclosing selectedNode=this. GetSelected ();
STR +=this. Invoke the (enclosing root);
} else {
STR +='Browser not supported.'
};
STR +='& lt;/div> ';
if (! Enclosing selectedFound) enclosing selectedNode=null;
This.com pleted=true;
Return the STR;
};
//Creates the tree structure
DTree. Prototype. Invoke the=function (pNode) {
Var STR=' ';
var n=0;
If (this. Config. InOrder) n=pNode. _ai;
For (n. nIf (this. ANodes [n]. Pid==pNode. Id) {
Var cn=this. ANodes [n].
Cn. _p=pNode;
Cn. _ai=n;
Enclosing setCS (cn);
if (! Cn. Target & amp; & This. Config. Target) cn. Target=this. Config. The target;
If (cn) _hc & amp; & ! Cn. _io & amp; & This. Config. UseCookies) cn. _io=this. IsOpen (cn. Id);
if (! This. Config. FolderLinks & amp; & Cn. _hc) cn. Url=null;
If (this. Config. UseSelection & amp; & Cn. Id==this. SelectedNode & amp; & ! Enclosing selectedFound) {
Cn. _is=true;
Enclosing selectedNode=n;
Enclosing selectedFound=true;
}
STR +=this. Node (cn, n);
If (cn) _ls) break;
}
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related