[code="html"]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
DSTree
<br> body,td{font:12px verdana}<br> #treeBox{background-color:#fffffa;}<br> #treeBox .ec{margin:0 5 0 5;}<br> #treeBox .hasItems{font-weight:bold;height:20px;padding:3 6 0 6;margin:2px;cursor:hand;color:#555555;border:1px solid #fffffa;}<br> #treeBox .Items{height:20px;padding:3 6 0 6;margin:1px;cursor:hand;color:#555555;border:1px solid #fffffa;}<br>
<br> //code by star 20003-4-7<br> var HC = "color:#990000;border:1px solid #cccccc";<br> var SC = "background-color:#efefef;border:1px solid #cccccc;color:#000000;";<br> var IO = null;<br> function initTree(){<br> var rootn = document.all.menuXML.documentElement;<br> var sd = 0;<br> document.onselectstart = function(){return false;}<br> document.all.treeBox.appendChild(createTree(rootn,sd));<br> }<br> function createTree(thisn,sd){<br> var nodeObj = document.createElement("span");<br> var upobj = document.createElement("span");<br> with(upobj){<br> style.marginLeft = sd*10;<br> className = thisn.hasChildNodes()?"hasItems":"Items";<br> innerHTML = "<img src=expand.gif class=ec>" + thisn.getAttribute("text") +"";</p> <p>onmousedown = function(){<br> if(event.button != 1) return;<br> if(this.getAttribute("cn")){<br> this.setAttribute("open",!this.getAttribute("open"));<br> this.cn.style.display = this.getAttribute("open")?"inline":"none";<br> this.all.tags("img")[0].src = this.getAttribute("open")?"expand.gif":"contract.gif";<br> }<br> if(IO){<br> IO.runtimeStyle.cssText = "";<br> IO.setAttribute("selected",false);<br> }<br> IO = this;<br> this.setAttribute("selected",true);<br> this.runtimeStyle.cssText = SC;<br> }<br> onmouseover = function(){<br> if(this.getAttribute("selected"))return;<br> this.runtimeStyle.cssText = HC;<br> }<br> onmouseout = function(){<br> if(this.getAttribute("selected"))return;<br> this.runtimeStyle.cssText = "";<br> }<br> oncontextmenu = contextMenuHandle;<br> onclick = clickHandle;<br> }</p> <p>if(thisn.getAttribute("treeId") != null){<br> upobj.setAttribute("treeId",thisn.getAttribute("treeId"));<br> }<br> if(thisn.getAttribute("href") != null){<br> upobj.setAttribute("href",thisn.getAttribute("href"));<br> }<br> if(thisn.getAttribute("target") != null){<br> upobj.setAttribute("target",thisn.getAttribute("target"));<br> }</p> <p>nodeObj.appendChild(upobj);<br> nodeObj.insertAdjacentHTML("beforeEnd","<br>")</p> <p>if(thisn.hasChildNodes()){<br> var i;<br> var nodes = thisn.childNodes;<br> var cn = document.createElement("span");<br> upobj.setAttribute("cn",cn);<br> if(thisn.getAttribute("open") != null){<br> upobj.setAttribute("open",(thisn.getAttribute("open")=="true"));<br> upobj.getAttribute("cn").style.display = upobj.getAttribute("open")?"inline":"none";<br> if( !upobj.getAttribute("open"))upobj.all.tags("img")[0].src ="contract.gif";<br> }</p> <p>for(i=0;i<nodes.length;cn.appendChild(createTree(nodes[i++],sd+1)));<br> nodeObj.appendChild(cn);<br> }<br> else{<br> upobj.all.tags("img")[0].src ="endnode.gif";<br> }<br> return nodeObj;<br> }<br> window.onload = initTree;<br> function clickHandle(){ // your code here } function contextMenuHandle(){ event.returnValue = false; var treeId = this.getAttribute("treeId"); // your code here }
<?xml version="1.0" encoding="GB2312"?>
by sTar 2003-4-8 |
[/code]
其中
的href中包含&字符,创建树失败,但是去掉&role=1,即不包含role时创建成功。
求解决办法。