200分求救——谁能给我一个类似目录树形菜单的javascript的代码?? http://www.chinaok.net/太多了.你还是在本栏查贴好! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <html><head><title>Untitled Document</title><meta http-equiv="Content-Type" content="text/html; charset=gb2312"><Style Type="text/css">.submit{ border-style:solid; border-width:1px; border-color:#778899; background-color: #FFFFFF; height: 16px; width: 12px;}.child{ display: none; padding-left:17px;}.item{ color: #0000FF; text-decoration: blink;}.text{ border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; background-color: #f8f8d0; color: #FF00FF;}</style><script language=javascript>var NS4=(document.layers)?true:falsewindow.status="|"function expand(el){ var Obj = eval("el" + el + "Child") var whichEl = (event) ? event.srcElement : false var parent = eval("document.myForm.parent"+el) if(!whichEl.name) whichEl = eval("document.all.img" + el) if(Obj.style.display == "") { Obj.style.display = "block" parent.value ="-" window.focus() } else { Obj.style.display = "" parent.value = "+" window.focus() } if(event) window.event.cancelBubble = true}</script></head><body topmargin=0 marginheight=0 leftmargin=0 marginwidth=0 bgcolor=#f8f8d0><form name=myForm action="" method="post"><table width=100% height=100% border=0 cellpadding=0 cellspacing=0> <tr> <td height=100% valign=top class=l15> <div id=el1Parent class=parent> <table border=0 cellspacing=0> <tr> <td><INPUT class=submit onclick=expand(1);return(false) type=button value=+ name=parent1></td> <td><a href=# onclick=expand(1);return(false) class=item><B>东京港</B></a></td> </tr> </table> </div> <div id=el1Child class=child> <div id=el11Parent class=parent> <table border="0" cellspacing="0"> <tr> <td><INPUT class=submit onclick=expand(11);return(false) type=button value=+ name=parent11></td> <td><a href=# onclick=expand(11);return(false) class=item>箱子1</a></td> </tr> </table> </div> <div id=el11Child class=child> item1<br/> item2<br/> item3 </div> <table border="0" cellspacing=0> <tr> <td><input disabled type="button" class=submit value=""></td> <td>箱子2</td> </tr> <tr> <td><input disabled type="button" class=submit value=""></td> <td>箱子3</td> </tr> </table> </div> <div id=el2Parent class=parent> <table border=0 cellspacing="0"> <tr> <td><INPUT class=submit onclick=expand(2);return(false) type=button value=+ name=parent2></td> <td><a href=# onclick=expand(2);return(false) class=item><b>大阪港</b></a></td> </tr> </table> </div> <div id=el2Child class=child> 箱子1<br/> 箱子2<br/> 箱子3<br/> </div> <div id=el3Parent class=parent> <table border=0 cellspacing=0> <tr> <td><INPUT class=submit onclick=expand(3);return(false) type=button value=+ name=parent3></td> <td><a href=# onclick=expand(3);return(false) class=item><b>古小牧港</b></a></td> </tr> </table> </div> <div id=el3Child class=child> 箱子1<br/> 箱子2<br/> 箱子3<br/> </div> </td> </tr></table></form></body></html> <HTML><HEAD><title>IE-Menu</title><script LANGUAGE="JavaScript"><!--//每个节点有一个数组,包含 4+n个元素 // node[0]为0/1 对应节点的展开/关闭// node[1]为0/1 对应文件夹的关闭/展开// node[2]为1 如果节点的子节点是文档// node[3]是节点的名称// node[4]...node[4+n]为n个子节点// 初始化菜单的数据function generateTree(){var aux1, aux2, aux3, aux4 foldersTree = folderNode("我的网站") aux1 = appendChild(foldersTree, folderNode("娱乐天地")) aux2 = appendChild(aux1, leafNode("literature")) appendChild(aux2, generateDocEntry(0, "文学巨著", "basefolder.htm", "")) appendChild(aux2, generateDocEntry(0, "杂家杂谈", "basefolder.htm", "")) aux2 = appendChild(aux1, leafNode("Music")) appendChild(aux2, generateDocEntry(0, "世纪流行风", "basefolder.htm", "")) appendChild(aux2, generateDocEntry(0, "民乐赏析", "basefolder.htm", "")) appendChild(aux2, generateDocEntry(0, "器乐演奏", "basefolder.htm", "")) aux1 = appendChild(foldersTree, folderNode("资料仓库")) aux2 = appendChild(aux1, leafNode("SoftWare")) appendChild(aux2,generateDocEntry(1, "系统软件", "basefolder.htm", "")) appendChild(aux2,generateDocEntry(1, "工具软件", "basefolder.htm", "")) appendChild(aux2,generateDocEntry(1, "游戏", "basefolder.htm", "")) aux2 = appendChild(aux1, folderNode("SourcePrograme")) aux3 = appendChild(aux2, leafNode("JavaScript")) appendChild(aux3, generateDocEntry(1, "第一期", "basefolder.htm","")) appendChild(aux3, generateDocEntry(1, "第二期", "basefolder.htm", "")) appendChild(aux3, generateDocEntry(1, "第三期", "basefolder.htm", "")) aux3 = appendChild(aux2, leafNode("ASP")) appendChild(aux3, generateDocEntry(1, "第一期", "basefolder.htm", "")) appendChild(aux3, generateDocEntry(1, "第二期", "basefolder.htm", "")) aux3 = appendChild(aux2, leafNode("PHP")) appendChild(aux3, generateDocEntry(1, "第一期", "basefolder.htm", "")) appendChild(aux3, generateDocEntry(1, "第二期", "basefolder.htm", "")) appendChild(aux3, generateDocEntry(1, "第三期", "basefolder.htm", "")) appendChild(aux3, generateDocEntry(1, "第四期", "basefolder.htm", "")) aux3 = appendChild(aux2, leafNode("CGI")) appendChild(aux3,generateDocEntry(1, "第一期", "basefolder.htm", "")) appendChild(aux3,generateDocEntry(1, "第二期", "basefolder.htm", "")) appendChild(aux3,generateDocEntry(1, "第三期", "basefolder.htm", "")) appendChild(aux3,generateDocEntry(1, "第四期", "basefolder.htm", "")) appendChild(aux3,generateDocEntry(1, "第五期", "basefolder.htm", "")) appendChild(aux3,generateDocEntry(1, "第六期", "basefolder.htm", "")) aux3 = appendChild(aux2, leafNode("另类")) appendChild(aux3, generateDocEntry(1, "Applet效果", "basefolder.htm", "")) appendChild(aux3, generateDocEntry(1, "Flash动画", "basefolder.htm", "")) aux2 = appendChild(aux1, folderNode("DownLoad Area")) aux3 = appendChild(aux2, leafNode("免费软件")) appendChild(aux3, generateDocEntry(1, "升级程序", "basefolder.htm", "")) appendChild(aux3, generateDocEntry(1, "补丁系列", "basefolder.htm", ""))}// 创建节点的辅助函数function folderNode(name){var arrayAux arrayAux = new Array arrayAux[0] = 0 arrayAux[1] = 0 arrayAux[2] = 0 arrayAux[3] = name return arrayAux}function leafNode(name){var arrayAux arrayAux = new Array arrayAux[0] = 0 arrayAux[1] = 0 arrayAux[2] = 1 arrayAux[3] = name return arrayAux}function appendChild(parent, child){ parent[parent.length] = child return child}function generateDocEntry(icon, docDescription, link){var retString ="" if (icon==0) retString = "<A href='"+link+"' target=folderFrame><img src='doc.gif' alt='在右边框架中打开'" else retString = "<A href='"+link+"' target=_blank><img src='link.gif' alt='在新窗口中打开'" retString = retString + " border=0></a><td nowrap><font style='font-size:9pt;font-family:宋体'>" + docDescription + "</font>" return retString}//刷新树状菜单function redrawTree(){var doc = top.treeFrame.window.document doc.clear() doc.write("<body bgcolor='white'>") redrawNode(foldersTree, doc, 0, 1, "") doc.close()}function redrawNode(foldersNode, doc, level, lastNode, leftSide){var j=0var i=0 doc.write("<table border=0 cellspacing=0 cellpadding=0>") doc.write("<tr><td valign = middle nowrap>") doc.write(leftSide) if (level>0) if (lastNode) //'brother'子节点数组中有否兄弟节点 { doc.write("<img src='lastnode.gif' width=16 height=22>") leftSide = leftSide + "<img src='blank.gif' width=16 height=22>" } else { doc.write("<img src='node.gif' width=16 height=22>") leftSide = leftSide + "<img src='vertline.gif' width=16 height=22>" } displayIconAndLabel(foldersNode, doc) doc.write("</table>") if (foldersNode.length > 4 && foldersNode[0]) //有更低层的节点和文件夹展开着 { if (!foldersNode[2])//带文件夹的文件夹 { level=level+1 for (i=4; i<foldersNode.length;i++) if (i==foldersNode.length-1) redrawNode(foldersNode[i], doc, level, 1, leftSide) else redrawNode(foldersNode[i], doc, level, 0, leftSide) } else //带文档的文件夹 { for (i=4; i<foldersNode.length;i++) { doc.write("<table border=0 cellspacing=0 cellpadding=0 valign=center>") doc.write("<tr><td nowrap>") doc.write(leftSide) if (i==foldersNode.length - 1) doc.write("<img src='lastnode.gif' width=16 height=22>") else doc.write("<img src='node.gif' width=16 height=22>") doc.write(foldersNode[i]) doc.write("</table>") } } }}function displayIconAndLabel(foldersNode, doc){ doc.write("<A href='javascript:top.openBranch(\"" + foldersNode[3] + "\")'><img src=") if (foldersNode[1]) doc.write("openfolder.gif width=24 height=22 border=noborder></a>") else doc.write("closedfolder.gif width=24 height=22 border=noborder></a>") doc.write("<td valign=middle align=left nowrap>") doc.write("<font style='font-size:9pt;font-family:宋体'>"+foldersNode[3]+"</font>")}//树收拢时调用的函数//当父节点关闭,其所有的子节点也都闭合function closeFolders(foldersNode){var i=0 if (!foldersNode[2]) { for (i=4; i< foldersNode.length; i++) closeFolders(foldersNode[i]) } foldersNode[0] = 0 foldersNode[1] = 0}//收拢节点function clickOnFolderRec(foldersNode, folderName){var i=0 if (foldersNode[3] == folderName) { if (foldersNode[0]) closeFolders(foldersNode) else { foldersNode[0] = 1 foldersNode[1] = 1 } } else { if (!foldersNode[2]) for (i=4; i< foldersNode.length; i++) clickOnFolderRec(foldersNode[i], folderName) }}//打开分支function openBranch(branchName){ clickOnFolderRec(foldersTree, branchName) if (branchName=="Start folder" && foldersTree[0]==0) top.folderFrame.location="basefolder.htm" timeOutId = setTimeout("redrawTree()",100)}//页面载入时的初始化function initializeTree(){ generateTree() redrawTree()}var foldersTree = 0var timeOutId = 0generateTree() --></script></HEAD><FRAMESET cols="200,*" onLoad='initializeTree()'> <FRAME src="basetree.htm" name="treeFrame"> <FRAME SRC="basefolder.htm" name="folderFrame"> </FRAMESET> </HTML> http://www.15seconds.com/issue/011113.htmhttp://www.15seconds.com/demo/011113/TreeAdmin.htmlhttp://www.ouzx.com <script language="JavaScript" class="a">var st=new Array(0,0,0,0,0,0,0,0,0,0);function openclose(tree,img,i){if(st[i]==0){tree.style.display="block";img.src="pic/open.gif";st[i]=1;}else{tree.style.display="none";img.src="pic/close.gif";st[i]=0;}}document.write('<table style="font:9pt 宋体" width="200" border="0" cellspacing="0" cellpadding="0">');document.write('<tr><td><a style="cursor:hand" onclick="openclose(menu1,img_menu1,1);"><img src="pic/close.gif" width="33" height="15" align="absmiddle" border="0" name="img_menu1">查询</a></td></tr>');document.write('<tr align="right" valign="top"><td>');document.write('<table id="menu1" style="display:none;font:9pt 宋体" width="180" border="0" cellspacing="0" cellpadding="0">');document.write('<tr align="right" valign="top"><td>');document.write('<table id="menu3" style="display:none;font:9pt 宋体" width="180" border="0" cellspacing="0" cellpadding="0">');document.write('<tr><td><a style="cursor:hand" ><img src="pic/circ.gif" width="33" height="15" align="absmiddle" border="0" name="img_menu4"></a><a href="t_htmx.asp?dat=1" target="frmright">合同浏览</a></td></tr>');document.write('<tr><td><a style="cursor:hand" ><img src="pic/circ.gif" width="33" height="15" align="absmiddle" border="0" name="img_menu4"></a><a href="t_dtmx.asp?dat=1" target="frmright">订单浏览</a></td></tr>');document.write('<tr><td><a style="cursor:hand" ><img src="pic/circ.gif" width="33" height="15" align="absmiddle" border="0" name="img_menu4"></a><a href="t_fymx.asp?dat=1" target="frmright">费用浏览</a></td></tr>');document.write('<tr><td><a style="cursor:hand" ><img src="pic/circ.gif" width="33" height="15" align="absmiddle" border="0" name="img_menu4"></a><a href="t_jhmx.asp?dat=1" target="frmright">机会浏览</a></td></tr>');document.write('<tr><td><a style="cursor:hand" ><img src="pic/circ.gif" width="33" height="15" align="absmiddle" border="0" name="img_menu4"></a><a href="t_yskjh.asp?dat=1" target="frmright">应收款计划浏览</a></td></tr>');document.write('<tr><td><a style="cursor:hand" ><img src="pic/circ.gif" width="33" height="15" align="absmiddle" border="0" name="img_menu4"></a><a href="t_skd.asp?dat=1" target="frmright">收款单浏览</a></td></tr>');document.write('</table></td></tr>');document.write('<tr><td><a style="cursor:hand" onclick="openclose(menu5,img_menu5,3);"><img src="pic/close.gif" width="33" height="15" align="absmiddle" border="0" name="img_menu5">计划任务</a></td></tr>');document.write('<tr align="right" valign="top"><td>');document.write('<table id="menu5" style="display:none;font:9pt 宋体" width="180" border="0" cellspacing="0" cellpadding="0">');document.write('<tr><td><a style="cursor:hand" ><img src="pic/circ.gif" width="33" height="15" align="absmiddle" border="0" name="img_menu6"></a><a href="p_jhrwgl.asp" target="frmright">计划任务管理</a></td></tr>');document.write('</table></td></tr>');document.write('<tr><td><a style="cursor:hand" onclick="openclose(menu7,img_menu7,4);"><img src="pic/close.gif" width="33" height="15" align="absmiddle" border="0" name="img_menu7">销售计划</a></td></tr>');document.write('<tr align="right" valign="top"><td>');document.write('<table id="menu7" style="display:none;font:9pt 宋体" width="180" border="0" cellspacing="0" cellpadding="0">');document.write('<tr><td><a style="cursor:hand" ><img src="pic/circ.gif" width="33" height="15" align="absmiddle" border="0" name="img_menu8"></a><a href="y_shchjh.asp" target="frmright">生成计划报表</a></td></tr>');document.write('<tr><td><a style="cursor:hand" ><img src="pic/circ.gif" width="33" height="15" align="absmiddle" border="0" name="img_menu8"></a><a href="y_hcdhp.asp" target="frmright">汇总到货品报表</a></td></tr>');document.write('</table></td></tr>');document.write('<tr><td><a style="cursor:hand" onclick="openclose(menu9,img_menu9,5);"><img src="pic/close.gif" width="33" height="15" align="absmiddle" border="0" name="img_menu9">财务支持</a></td></tr>');document.write('<tr align="right" valign="top"><td>');document.write('<table id="menu9" style="display:none;font:9pt 宋体" width="180" border="0" cellspacing="0" cellpadding="0">');document.write('<tr><td><a style="cursor:hand" ><img src="pic/circ.gif" width="33" height="15" align="absmiddle" border="0" name="img_menu10"></a><a href="c_cbfx.asp" target="frmright">成本分析</a></td></tr>');document.write('</table></td></tr>');document.write('<tr><td><a style="cursor:hand" onclick="openclose(menu11,img_menu11,6);"><img src="pic/close.gif" width="33" height="15" align="absmiddle" border="0" name="img_menu11">业务报表</a></td></tr>');</script> 收藏了“阿信”写的程序,你下载回去看吧,很不错!:-)http://www.jiangdu.net/download/deeptree.rar http://www.njcatv.net/javascript有很多你要的! 下载一个webmenushop要做什么样的树形目录都可以 这个不错:http://webfx.eae.net/dhtml/xtree/index.html ydr2002,你的例子真不错!但是好像没看到源码呀:( 奇怪,為什么xtree用cookie寫的而別的代碼都不是誰能解釋一下嗎,謝過 to : ruir() 你的程序我试过了,可左边只是显示basetree.htm的内容,好像并不执行页面载入时的onload var mimgpath="treeimg";var mfonts="style=\"text-decoration:none;font-family: 宋体; font-size: 9pt; color: #000000; \"";var movercolor="#0000FF";var mnormalcolor="#000000";var NC6=(navigator.userAgent.indexOf("Netscape6")>0)?true:false;var IE=(document.all)?true:false;function mOver(id) {if (IE) {eval(id).style.color=movercolor; } else if(NC6){ document.getElementById(id).style.color=movercolor;}}function mOut(id) {if (IE) {eval(id).style.color=mnormalcolor; } else if(NC6){ document.getElementById(id).style.color=mnormalcolor;}}function mFolderExpand($1,$2,pic) { if (IE) { mExpandIE($1,$2,pic) } else if(NC6){ mExpandNC($1,$2,pic) }}function mExpandIE($1,$2,pic) { Expanda = eval($1 + "a"); Expanda.blur() ExpandChild = eval($1 + "Child"); if ($2 != "top") { ExpandTree = eval($1 + "Tree"); //ExpandFolder = eval($1 + "Folder"); } if (ExpandChild.style.display == "none") { ExpandChild.style.display = "block"; if ($2 != "top") { if ($2 == "last") { ExpandTree.src = mimgpath+"/Lminus.gif"; } else { ExpandTree.src = mimgpath+"/Tminus.gif"; } //ExpandFolder.src = mimgpath+"/openfolder"+pic+".gif"; } else { mmTree.src = mimgpath+"/topopen1.gif"; } }else{ ExpandChild.style.display = "none"; if ($2 != "top") { if ($2 == "last") { ExpandTree.src = mimgpath+"/Lplus.gif"; } else { ExpandTree.src = mimgpath+"/Tplus.gif"; } //ExpandFolder.src = mimgpath+"/folder"+pic+".gif"; } else { mmTree.src = mimgpath+"/top1.gif"; } }}function mExpandNC($1,$2,pic) { Expanda = document.getElementById($1 + "a"); Expanda.blur() ExpandChild = document.getElementById($1 + "Child"); if ($2 != "top") { ExpandTree = document.getElementById($1 + "Tree"); //ExpandFolder = document.getElementById($1 + "Folder"); } if (ExpandChild.style.display == "none") { ExpandChild.style.display = "block"; if ($2 != "top") { if ($2 == "last") { ExpandTree.src = mimgpath+"/Lminus.gif"; } else { ExpandTree.src = mimgpath+"/Tminus.gif"; } //ExpandFolder.src = mimgpath+"/openfolder"+pic+".gif"; } else { document.getElementById("mmTree").src = mimgpath+"/topopen1.gif"; } }else{ ExpandChild.style.display = "none"; if ($2 != "top") { if ($2 == "last") { ExpandTree.src = mimgpath+"/Lplus.gif"; } else { ExpandTree.src = mimgpath+"/Tplus.gif"; } //ExpandFolder.src = mimgpath+"/folder"+pic+".gif"; } else {document.getElementById("mmTree").src = mimgpath+"/top1.gif"; } }}with(document){write("<div ID=\"mmParent\"><a ID=\"mma\" href=\"#\" style=\"text-decoration:none;font-family: 宋体; font-size: 9pt; color: #000000; \" onClick=\"mFolderExpand('mm','top',null)\">");write("<img ID=\"mmTree\" src=\""+mimgpath+"/topopen1.gif\" style=\"margin-right: 5\" align=\"absmiddle\" border=\"0\">");write("<font ID=\"mTitle0\" onmouseover=\"mOver('mTitle0')\" onmouseout=\"mOut('mTitle0')\"></font></a></div>");write("<div ID=\"mmChild\"><div ID=\"mm1Parent\"><a ID=\"mm1a\" target=\"_self\" href=\"#\" "+mfonts+" onClick=\"mFolderExpand('mm1',null,'4')\" title=\"\">");write("<img ID=\"mm1Tree\" src=\""+mimgpath+"/Tplus.gif\" align=\"absmiddle\" border=\"0\"><font ID=\"mTitle1\" onmouseover=\"mOver('mTitle1')\" onmouseout=\"mOut('mTitle1')\">文件</font></a>");write("</div>");write("<div ID=\"mm1Child\" style=\"display:none;\">");write("<div ID=\"mm2Parent\"><a ID=\"mm2a\" target=\"_self\" href=\"#\" "+mfonts+" onClick=\"mFolderExpand('mm2',null,'0')\" title=\"\">");write("<img src=\""+mimgpath+"/I.gif\" align=\"absmiddle\" width=\"19\" height=\"20\" border=\"0\"><img ID=\"mm2Tree\" src=\""+mimgpath+"/Tplus.gif\" align=\"absmiddle\" border=\"0\"><font ID=\"mTitle2\" onmouseover=\"mOver('mTitle2')\" onmouseout=\"mOut('mTitle2')\">新建</font></a>");write("</div>");write("<div ID=\"mm2Child\" style=\"display:none;\">");write("<img src=\""+mimgpath+"/I.gif\" align=\"absmiddle\" width=\"19\" height=\"20\" border=\"0\"><img src=\""+mimgpath+"/I.gif\" align=\"absmiddle\" width=\"19\" height=\"20\" border=\"0\"><img src=\""+mimgpath+"/L.gif\" align=\"absmiddle\" width=\"19\" height=\"20\" border=\"0\"><a target=\"mainFrame\" href=\"main.htm\" "+mfonts+" title=\"\"><font ID=\"mTitle3\" onmouseover=\"mOver('mTitle3')\" onmouseout=\"mOut('mTitle3')\">新建文件</font></a><br/>");write("</div>");write("<img src=\""+mimgpath+"/I.gif\" align=\"absmiddle\" width=\"19\" height=\"20\" border=\"0\"><img src=\""+mimgpath+"/L.gif\" align=\"absmiddle\" width=\"19\" height=\"20\" border=\"0\"><a target=\"mainFrame\" href=\"main1.htm\" "+mfonts+" title=\"\"><font ID=\"mTitle4\" onmouseover=\"mOver('mTitle4')\" onmouseout=\"mOut('mTitle4')\">新建菜单</font></a><br/>");write("</div>");write("<img src=\""+mimgpath+"/L.gif\" align=\"absmiddle\" width=\"19\" height=\"20\" border=\"0\"><a target=\"_self\" href=\"#\" "+mfonts+" title=\"\"><font ID=\"mTitle5\" onmouseover=\"mOver('mTitle5')\" onmouseout=\"mOut('mTitle5')\">系统</font></a><br/>");write("</div>");}这是用webmenushop做的调用时只要在相应的页面上写上<script language="javascript" src="menu.js"></script>就可以了,当然还需要“+”号的图片前面的程序应该放在以menu.js为名字的文件中 <html><head><title>Untitled Document</title><Script Language="JavaScript">//以下代码实现树var strStyle='<style type="text/css">'strStyle+='span.SelectIng{color:#ff00ff;border:solid 1pt #666666;padding:0.5pt;height:4px;background-color:#cccccc;}'strStyle+='span.NoSelect{color:#000084;border:solid 1pt #ffffff;padding:0.5pt;height:4px;background-color:#ffffff;}'strStyle+='span.SelectEd{color:#D02090;border:solid 1pt #888888;padding:0.5pt;height:4px;background-color:#f3f3f3;}'strStyle+='</style>'document.write(strStyle)var myRs=new Array(), selectItem;function compare(a,b) {return parseInt(a[1]) - parseInt(b[1])}function InsertItem(s){myRs[myRs.length++] = s.split(/,/);}function ExCloAll(n){ var d=document.all('0'), e=d.all.tags('div') for (i=0;i<e.length;i++)e[i].style.display=(n==1?'block':'none') e=d.all.tags('p') for (i=0;i<e.length;i++){if(ChkExist(e[i].children[1].value))e[i].children[0].src=(n==1?'images/open.png':'images/close.png')}}function ExCloItem(){ var c,e=event.srcElement, p=e.parentElement.children if(e.myHref!=''){ eval((e.myTarget!=''?e.myTarget:'parent.mainFrame')+'.location.href='+'e.myHref') //要改成?接到某?只需把alert改成eval即可 } window.status=e.innerText; if(selectItem!=null)selectItem.className='NoSelect'; e.className='SelectEd' selectItem=event.srcElement; if(c=document.all(e.value)){ p[0].src=(c.style.display=='none'?'images/open.png':'images/close.png') c.style.display=(c.style.display=='none'?'block':'none') }else{p[0].src='images/window.gif'}}function ExCloItem2(){ var c,e=event.srcElement, p=e.parentElement.children if(c=document.all(p[1].value)){ e.src=(c.style.display=='none'?'images/open.png':'images/close.png') c.style.display=(c.style.display=='block'?'none':'block') }else e.src='images/window.gif'}function OutItem(){ var e=event.srcElement if(selectItem != '')e.className=(selectItem==e?'SelectEd':'NoSelect') else e.className='NoSelect'}function ChkExist(n){ n=parseInt(n) if((n<myRs[0][1])||(n>myRs[myRs.length-1][1]))return false var a,b,c,x=0, y=parseInt(myRs.length/2), z=myRs.length-1 while((x!=y)&&(y!=z)){ a=myRs[x][1], b=myRs[y][1], c=myRs[z][1] if(n==a||n==b||n==c)return true if(n>b)x=y; else z=y;y=parseInt(x+z); y=parseInt((x+z)/2); } return false}function drawTree(n){ if(n==0){ myRs.sort(compare) document.write('<p style="font:10pt;cursor:hand;"><b><font color="#0099FF" size="2"><span onclick="ExCloAll(1)">展示全部模块</span><br><span onclick="ExCloAll(0)">关闭全部模块</span></font></b></p>') } if (ChkExist(n)!=true)return document.write('<div id="'+n+'" style="font:10pt;cursor:hand;'+(n!=0?'position:relative;left:20;display:none;':'')+'">') for(var i=0;i<myRs.length;i++){ //if (parseInt(myRs[i][1])>n)break; if (myRs[i][1]==n){ document.write('<p style="margin:0pt;"><img src='+(ChkExist(myRs[i][0])?"images/close.png":"images/window.gif" )+' width="16" height="16" onclick="ExCloItem2()">') document.write('<span onclick="ExCloItem()" myHref="'+(myRs[i].length>3?myRs[i][3]:'')+'" myTarget="' + (myRs[i].length>4?myRs[i][4]:'') +'" value="'+myRs[i][0]+'" class="NoSelect" onmouseout="OutItem()" onmouseover="this.className=\'SelectIng\'">'+myRs[i][2]+'</span></p>') //if (myRs[i].length >3)document.write('</a>'); drawTree(myRs[i][0]) } } document.write('</div>')}InsertItem('1,0,生产计划,,');InsertItem('2,0,库存管理,,');InsertItem('3,0,生产操作费,,');InsertItem('4,0,生产预警,,');InsertItem('5,1,油产计划,,');InsertItem('6,5,油产计划查询,oilplan.jsp,');InsertItem('7,1,气产计划,,');InsertItem('8,2,油库存查询,http://www.sina.com.cn,');InsertItem('9,2,副产品库存,,');InsertItem('10,9,LPG,LPG.jsp,');InsertItem('11,9,戊烷,戊烷.jsp,');InsertItem('12,9,轻烃,轻烃.jsp,');InsertItem('13,7,干气,,');InsertItem('14,13,干气查询,,');InsertItem('15,14,查询例子集,,');InsertItem('16,15,查询例子,example.jsp,');InsertItem('17,4,生产预警1,,');InsertItem('18,3,搜狐,http://www.sohu.com,');InsertItem('19,3,不同发布项目测试,http://olapsvr/Project1/test.jsp,');drawTree(0)</Script></head><body bgcolor="#FFFFFF" text="#000000"></body></html> http://hshlin.8u8.com/code manager.rar去下吧,asp+access,完美树结构 jquery时间函数 用javascript让图片每秒移动一下的问题,新手请求帮助 Jquery 的判断问题 ie上不行 关于JS 对象的问题 长度为25个字符的Javascript能干什么? 急急急急急急急急急急急急急急急急急急急急急急急急急急急 同时return true时才能submit怎么做。。 急阿,如何动态取得div里面的table、tr等? 如何让复选框不可编辑 ext 怎么设置grid样式 javascript里有没有可以获得当前窗口里被激活的控件的方法??(急!!在线等待!!) 谁能给一个简单的菜单的例子!谢谢了
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<Style Type="text/css">
.submit
{
border-style:solid;
border-width:1px;
border-color:#778899;
background-color: #FFFFFF;
height: 16px;
width: 12px;
}
.child
{
display: none;
padding-left:17px;
}
.item
{
color: #0000FF;
text-decoration: blink;
}
.text
{
border-top-width: 0px;
border-right-width: 0px;
border-bottom-width: 0px;
border-left-width: 0px;
border-top-style: none;
border-right-style: none;
border-bottom-style: none;
border-left-style: none;
background-color: #f8f8d0;
color: #FF00FF;
}
</style>
<script language=javascript>
var NS4=(document.layers)?true:false
window.status="|"
function expand(el)
{
var Obj = eval("el" + el + "Child")
var whichEl = (event) ? event.srcElement : false
var parent = eval("document.myForm.parent"+el)
if(!whichEl.name) whichEl = eval("document.all.img" + el)
if(Obj.style.display == "")
{
Obj.style.display = "block"
parent.value ="-"
window.focus()
}
else
{
Obj.style.display = ""
parent.value = "+"
window.focus()
}
if(event) window.event.cancelBubble = true
}</script></head><body topmargin=0 marginheight=0 leftmargin=0 marginwidth=0 bgcolor=#f8f8d0>
<form name=myForm action="" method="post">
<table width=100% height=100% border=0 cellpadding=0 cellspacing=0>
<tr>
<td height=100% valign=top class=l15>
<div id=el1Parent class=parent>
<table border=0 cellspacing=0>
<tr>
<td><INPUT class=submit onclick=expand(1);return(false) type=button value=+ name=parent1></td>
<td><a href=# onclick=expand(1);return(false) class=item><B>东京港</B></a></td>
</tr>
</table>
</div>
<div id=el1Child class=child>
<div id=el11Parent class=parent>
<table border="0" cellspacing="0">
<tr>
<td><INPUT class=submit onclick=expand(11);return(false) type=button value=+ name=parent11></td>
<td><a href=# onclick=expand(11);return(false) class=item>箱子1</a></td>
</tr>
</table>
</div>
<div id=el11Child class=child>
item1<br/>
item2<br/>
item3
</div>
<table border="0" cellspacing=0>
<tr>
<td><input disabled type="button" class=submit value=""></td>
<td>箱子2</td>
</tr>
<tr>
<td><input disabled type="button" class=submit value=""></td>
<td>箱子3</td>
</tr>
</table> </div>
<div id=el2Parent class=parent>
<table border=0 cellspacing="0">
<tr>
<td><INPUT class=submit onclick=expand(2);return(false) type=button value=+ name=parent2></td>
<td><a href=# onclick=expand(2);return(false) class=item><b>大阪港</b></a></td>
</tr>
</table>
</div>
<div id=el2Child class=child>
箱子1<br/>
箱子2<br/>
箱子3<br/>
</div>
<div id=el3Parent class=parent>
<table border=0 cellspacing=0>
<tr>
<td><INPUT class=submit onclick=expand(3);return(false) type=button value=+ name=parent3></td>
<td><a href=# onclick=expand(3);return(false) class=item><b>古小牧港</b></a></td>
</tr>
</table>
</div>
<div id=el3Child class=child>
箱子1<br/>
箱子2<br/>
箱子3<br/>
</div>
</td>
</tr>
</table>
</form></body></html>
<HEAD>
<title>IE-Menu</title><script LANGUAGE="JavaScript">
<!--
//每个节点有一个数组,包含 4+n个元素
// node[0]为0/1 对应节点的展开/关闭
// node[1]为0/1 对应文件夹的关闭/展开
// node[2]为1 如果节点的子节点是文档
// node[3]是节点的名称
// node[4]...node[4+n]为n个子节点// 初始化菜单的数据function generateTree()
{
var aux1, aux2, aux3, aux4 foldersTree = folderNode("我的网站")
aux1 = appendChild(foldersTree, folderNode("娱乐天地"))
aux2 = appendChild(aux1, leafNode("literature"))
appendChild(aux2, generateDocEntry(0, "文学巨著", "basefolder.htm", ""))
appendChild(aux2, generateDocEntry(0, "杂家杂谈", "basefolder.htm", ""))
aux2 = appendChild(aux1, leafNode("Music"))
appendChild(aux2, generateDocEntry(0, "世纪流行风", "basefolder.htm", ""))
appendChild(aux2, generateDocEntry(0, "民乐赏析", "basefolder.htm", ""))
appendChild(aux2, generateDocEntry(0, "器乐演奏", "basefolder.htm", ""))
aux1 = appendChild(foldersTree, folderNode("资料仓库"))
aux2 = appendChild(aux1, leafNode("SoftWare"))
appendChild(aux2,generateDocEntry(1, "系统软件", "basefolder.htm", ""))
appendChild(aux2,generateDocEntry(1, "工具软件", "basefolder.htm", ""))
appendChild(aux2,generateDocEntry(1, "游戏", "basefolder.htm", ""))
aux2 = appendChild(aux1, folderNode("SourcePrograme"))
aux3 = appendChild(aux2, leafNode("JavaScript"))
appendChild(aux3, generateDocEntry(1, "第一期", "basefolder.htm",""))
appendChild(aux3, generateDocEntry(1, "第二期", "basefolder.htm", ""))
appendChild(aux3, generateDocEntry(1, "第三期", "basefolder.htm", ""))
aux3 = appendChild(aux2, leafNode("ASP"))
appendChild(aux3, generateDocEntry(1, "第一期", "basefolder.htm", ""))
appendChild(aux3, generateDocEntry(1, "第二期", "basefolder.htm", ""))
aux3 = appendChild(aux2, leafNode("PHP"))
appendChild(aux3, generateDocEntry(1, "第一期", "basefolder.htm", ""))
appendChild(aux3, generateDocEntry(1, "第二期", "basefolder.htm", ""))
appendChild(aux3, generateDocEntry(1, "第三期", "basefolder.htm", ""))
appendChild(aux3, generateDocEntry(1, "第四期", "basefolder.htm", ""))
aux3 = appendChild(aux2, leafNode("CGI"))
appendChild(aux3,generateDocEntry(1, "第一期", "basefolder.htm", ""))
appendChild(aux3,generateDocEntry(1, "第二期", "basefolder.htm", ""))
appendChild(aux3,generateDocEntry(1, "第三期", "basefolder.htm", ""))
appendChild(aux3,generateDocEntry(1, "第四期", "basefolder.htm", ""))
appendChild(aux3,generateDocEntry(1, "第五期", "basefolder.htm", ""))
appendChild(aux3,generateDocEntry(1, "第六期", "basefolder.htm", ""))
aux3 = appendChild(aux2, leafNode("另类"))
appendChild(aux3, generateDocEntry(1, "Applet效果", "basefolder.htm", ""))
appendChild(aux3, generateDocEntry(1, "Flash动画", "basefolder.htm", ""))
aux2 = appendChild(aux1, folderNode("DownLoad Area"))
aux3 = appendChild(aux2, leafNode("免费软件"))
appendChild(aux3, generateDocEntry(1, "升级程序", "basefolder.htm", ""))
appendChild(aux3, generateDocEntry(1, "补丁系列", "basefolder.htm", ""))
}// 创建节点的辅助函数
function folderNode(name)
{
var arrayAux
arrayAux = new Array
arrayAux[0] = 0
arrayAux[1] = 0
arrayAux[2] = 0
arrayAux[3] = name
return arrayAux
}
function leafNode(name)
{
var arrayAux
arrayAux = new Array
arrayAux[0] = 0
arrayAux[1] = 0
arrayAux[2] = 1
arrayAux[3] = name
return arrayAux
}function appendChild(parent, child)
{
parent[parent.length] = child
return child
}function generateDocEntry(icon, docDescription, link)
{
var retString ="" if (icon==0)
retString = "<A href='"+link+"' target=folderFrame><img src='doc.gif' alt='在右边框架中打开'"
else
retString = "<A href='"+link+"' target=_blank><img src='link.gif' alt='在新窗口中打开'"
retString = retString + " border=0></a><td nowrap><font style='font-size:9pt;font-family:宋体'>" + docDescription + "</font>" return retString}
//刷新树状菜单
function redrawTree()
{
var doc = top.treeFrame.window.document doc.clear()
doc.write("<body bgcolor='white'>")
redrawNode(foldersTree, doc, 0, 1, "")
doc.close()
}function redrawNode(foldersNode, doc, level, lastNode, leftSide)
{
var j=0
var i=0 doc.write("<table border=0 cellspacing=0 cellpadding=0>")
doc.write("<tr><td valign = middle nowrap>") doc.write(leftSide) if (level>0)
if (lastNode) //'brother'子节点数组中有否兄弟节点
{
doc.write("<img src='lastnode.gif' width=16 height=22>")
leftSide = leftSide + "<img src='blank.gif' width=16 height=22>"
}
else
{
doc.write("<img src='node.gif' width=16 height=22>")
leftSide = leftSide + "<img src='vertline.gif' width=16 height=22>"
} displayIconAndLabel(foldersNode, doc)
doc.write("</table>") if (foldersNode.length > 4 && foldersNode[0]) //有更低层的节点和文件夹展开着
{
if (!foldersNode[2])//带文件夹的文件夹
{
level=level+1
for (i=4; i<foldersNode.length;i++)
if (i==foldersNode.length-1)
redrawNode(foldersNode[i], doc, level, 1, leftSide)
else
redrawNode(foldersNode[i], doc, level, 0, leftSide)
}
else //带文档的文件夹
{
for (i=4; i<foldersNode.length;i++)
{
doc.write("<table border=0 cellspacing=0 cellpadding=0 valign=center>")
doc.write("<tr><td nowrap>")
doc.write(leftSide)
if (i==foldersNode.length - 1)
doc.write("<img src='lastnode.gif' width=16 height=22>")
else
doc.write("<img src='node.gif' width=16 height=22>")
doc.write(foldersNode[i])
doc.write("</table>")
}
}
}
}function displayIconAndLabel(foldersNode, doc)
{
doc.write("<A href='javascript:top.openBranch(\"" + foldersNode[3] + "\")'><img src=")
if (foldersNode[1])
doc.write("openfolder.gif width=24 height=22 border=noborder></a>")
else
doc.write("closedfolder.gif width=24 height=22 border=noborder></a>")
doc.write("<td valign=middle align=left nowrap>")
doc.write("<font style='font-size:9pt;font-family:宋体'>"+foldersNode[3]+"</font>")
}
//树收拢时调用的函数//当父节点关闭,其所有的子节点也都闭合
function closeFolders(foldersNode)
{
var i=0 if (!foldersNode[2])
{
for (i=4; i< foldersNode.length; i++)
closeFolders(foldersNode[i]) }
foldersNode[0] = 0
foldersNode[1] = 0
}//收拢节点
function clickOnFolderRec(foldersNode, folderName)
{
var i=0 if (foldersNode[3] == folderName)
{
if (foldersNode[0])
closeFolders(foldersNode)
else
{
foldersNode[0] = 1
foldersNode[1] = 1
}
}
else
{
if (!foldersNode[2])
for (i=4; i< foldersNode.length; i++)
clickOnFolderRec(foldersNode[i], folderName)
}
}
//打开分支
function openBranch(branchName)
{
clickOnFolderRec(foldersTree, branchName)
if (branchName=="Start folder" && foldersTree[0]==0)
top.folderFrame.location="basefolder.htm"
timeOutId = setTimeout("redrawTree()",100)
}//页面载入时的初始化
function initializeTree()
{
generateTree()
redrawTree()
}var foldersTree = 0
var timeOutId = 0
generateTree()
-->
</script>
</HEAD><FRAMESET cols="200,*" onLoad='initializeTree()'>
<FRAME src="basetree.htm" name="treeFrame">
<FRAME SRC="basefolder.htm" name="folderFrame">
</FRAMESET>
</HTML>
http://www.15seconds.com/demo/011113/TreeAdmin.html
http://www.ouzx.com
var st=new Array(0,0,0,0,0,0,0,0,0,0);
function openclose(tree,img,i){
if(st[i]==0)
{tree.style.display="block";img.src="pic/open.gif";st[i]=1;}
else
{tree.style.display="none";img.src="pic/close.gif";st[i]=0;}}
document.write('<table style="font:9pt 宋体" width="200" border="0" cellspacing="0" cellpadding="0">');
document.write('<tr><td><a style="cursor:hand" onclick="openclose(menu1,img_menu1,1);"><img src="pic/close.gif" width="33" height="15" align="absmiddle" border="0" name="img_menu1">查询</a></td></tr>');
document.write('<tr align="right" valign="top"><td>');
document.write('<table id="menu1" style="display:none;font:9pt 宋体" width="180" border="0" cellspacing="0" cellpadding="0">');document.write('<tr align="right" valign="top"><td>');
document.write('<table id="menu3" style="display:none;font:9pt 宋体" width="180" border="0" cellspacing="0" cellpadding="0">');
document.write('<tr><td><a style="cursor:hand" ><img src="pic/circ.gif" width="33" height="15" align="absmiddle" border="0" name="img_menu4"></a><a href="t_htmx.asp?dat=1" target="frmright">合同浏览</a></td></tr>');
document.write('<tr><td><a style="cursor:hand" ><img src="pic/circ.gif" width="33" height="15" align="absmiddle" border="0" name="img_menu4"></a><a href="t_dtmx.asp?dat=1" target="frmright">订单浏览</a></td></tr>');
document.write('<tr><td><a style="cursor:hand" ><img src="pic/circ.gif" width="33" height="15" align="absmiddle" border="0" name="img_menu4"></a><a href="t_fymx.asp?dat=1" target="frmright">费用浏览</a></td></tr>');
document.write('<tr><td><a style="cursor:hand" ><img src="pic/circ.gif" width="33" height="15" align="absmiddle" border="0" name="img_menu4"></a><a href="t_jhmx.asp?dat=1" target="frmright">机会浏览</a></td></tr>');
document.write('<tr><td><a style="cursor:hand" ><img src="pic/circ.gif" width="33" height="15" align="absmiddle" border="0" name="img_menu4"></a><a href="t_yskjh.asp?dat=1" target="frmright">应收款计划浏览</a></td></tr>');
document.write('<tr><td><a style="cursor:hand" ><img src="pic/circ.gif" width="33" height="15" align="absmiddle" border="0" name="img_menu4"></a><a href="t_skd.asp?dat=1" target="frmright">收款单浏览</a></td></tr>');document.write('</table></td></tr>');document.write('<tr><td><a style="cursor:hand" onclick="openclose(menu5,img_menu5,3);"><img src="pic/close.gif" width="33" height="15" align="absmiddle" border="0" name="img_menu5">计划任务</a></td></tr>');
document.write('<tr align="right" valign="top"><td>');
document.write('<table id="menu5" style="display:none;font:9pt 宋体" width="180" border="0" cellspacing="0" cellpadding="0">');
document.write('<tr><td><a style="cursor:hand" ><img src="pic/circ.gif" width="33" height="15" align="absmiddle" border="0" name="img_menu6"></a><a href="p_jhrwgl.asp" target="frmright">计划任务管理</a></td></tr>');
document.write('</table></td></tr>');document.write('<tr><td><a style="cursor:hand" onclick="openclose(menu7,img_menu7,4);"><img src="pic/close.gif" width="33" height="15" align="absmiddle" border="0" name="img_menu7">销售计划</a></td></tr>');
document.write('<tr align="right" valign="top"><td>');
document.write('<table id="menu7" style="display:none;font:9pt 宋体" width="180" border="0" cellspacing="0" cellpadding="0">');
document.write('<tr><td><a style="cursor:hand" ><img src="pic/circ.gif" width="33" height="15" align="absmiddle" border="0" name="img_menu8"></a><a href="y_shchjh.asp" target="frmright">生成计划报表</a></td></tr>');
document.write('<tr><td><a style="cursor:hand" ><img src="pic/circ.gif" width="33" height="15" align="absmiddle" border="0" name="img_menu8"></a><a href="y_hcdhp.asp" target="frmright">汇总到货品报表</a></td></tr>');
document.write('</table></td></tr>');document.write('<tr><td><a style="cursor:hand" onclick="openclose(menu9,img_menu9,5);"><img src="pic/close.gif" width="33" height="15" align="absmiddle" border="0" name="img_menu9">财务支持</a></td></tr>');
document.write('<tr align="right" valign="top"><td>');
document.write('<table id="menu9" style="display:none;font:9pt 宋体" width="180" border="0" cellspacing="0" cellpadding="0">');
document.write('<tr><td><a style="cursor:hand" ><img src="pic/circ.gif" width="33" height="15" align="absmiddle" border="0" name="img_menu10"></a><a href="c_cbfx.asp" target="frmright">成本分析</a></td></tr>');
document.write('</table></td></tr>');document.write('<tr><td><a style="cursor:hand" onclick="openclose(menu11,img_menu11,6);"><img src="pic/close.gif" width="33" height="15" align="absmiddle" border="0" name="img_menu11">业务报表</a></td></tr>');
</script>
:-)http://www.jiangdu.net/download/deeptree.rar
http://webfx.eae.net/dhtml/xtree/index.html
而別的代碼都不是
誰能解釋一下嗎,謝過
你的程序我试过了,可左边只是显示basetree.htm的内容,好像并不执行页面载入时的onload
var mimgpath="treeimg";
var mfonts="style=\"text-decoration:none;font-family: 宋体; font-size: 9pt; color: #000000; \"";
var movercolor="#0000FF";
var mnormalcolor="#000000";
var NC6=(navigator.userAgent.indexOf("Netscape6")>0)?true:false;
var IE=(document.all)?true:false;
function mOver(id) {
if (IE) {eval(id).style.color=movercolor; }
else if(NC6){ document.getElementById(id).style.color=movercolor;}
}
function mOut(id) {
if (IE) {eval(id).style.color=mnormalcolor; }
else if(NC6){ document.getElementById(id).style.color=mnormalcolor;}
}function mFolderExpand($1,$2,pic) {
if (IE) { mExpandIE($1,$2,pic) }
else if(NC6){ mExpandNC($1,$2,pic) }
}function mExpandIE($1,$2,pic) {
Expanda = eval($1 + "a");
Expanda.blur()
ExpandChild = eval($1 + "Child");
if ($2 != "top") {
ExpandTree = eval($1 + "Tree");
//ExpandFolder = eval($1 + "Folder");
}
if (ExpandChild.style.display == "none") {
ExpandChild.style.display = "block";
if ($2 != "top") {
if ($2 == "last") { ExpandTree.src = mimgpath+"/Lminus.gif"; }
else { ExpandTree.src = mimgpath+"/Tminus.gif"; }
//ExpandFolder.src = mimgpath+"/openfolder"+pic+".gif";
}
else { mmTree.src = mimgpath+"/topopen1.gif"; }
}else{
ExpandChild.style.display = "none";
if ($2 != "top") {
if ($2 == "last") { ExpandTree.src = mimgpath+"/Lplus.gif"; }
else { ExpandTree.src = mimgpath+"/Tplus.gif"; }
//ExpandFolder.src = mimgpath+"/folder"+pic+".gif";
}
else { mmTree.src = mimgpath+"/top1.gif"; }
}
}
function mExpandNC($1,$2,pic) {
Expanda = document.getElementById($1 + "a");
Expanda.blur()
ExpandChild = document.getElementById($1 + "Child");
if ($2 != "top") {
ExpandTree = document.getElementById($1 + "Tree");
//ExpandFolder = document.getElementById($1 + "Folder");
}
if (ExpandChild.style.display == "none") {
ExpandChild.style.display = "block";
if ($2 != "top") {
if ($2 == "last") { ExpandTree.src = mimgpath+"/Lminus.gif"; }
else { ExpandTree.src = mimgpath+"/Tminus.gif"; }
//ExpandFolder.src = mimgpath+"/openfolder"+pic+".gif";
}
else { document.getElementById("mmTree").src = mimgpath+"/topopen1.gif"; }
}else{
ExpandChild.style.display = "none";
if ($2 != "top") {
if ($2 == "last") { ExpandTree.src = mimgpath+"/Lplus.gif"; }
else { ExpandTree.src = mimgpath+"/Tplus.gif"; }
//ExpandFolder.src = mimgpath+"/folder"+pic+".gif";
}
else {document.getElementById("mmTree").src = mimgpath+"/top1.gif"; }
}
}
with(document){
write("<div ID=\"mmParent\"><a ID=\"mma\" href=\"#\" style=\"text-decoration:none;font-family: 宋体; font-size: 9pt; color: #000000; \" onClick=\"mFolderExpand('mm','top',null)\">");
write("<img ID=\"mmTree\" src=\""+mimgpath+"/topopen1.gif\" style=\"margin-right: 5\" align=\"absmiddle\" border=\"0\">");
write("<font ID=\"mTitle0\" onmouseover=\"mOver('mTitle0')\" onmouseout=\"mOut('mTitle0')\"></font></a></div>");
write("<div ID=\"mmChild\"><div ID=\"mm1Parent\"><a ID=\"mm1a\" target=\"_self\" href=\"#\" "+mfonts+" onClick=\"mFolderExpand('mm1',null,'4')\" title=\"\">");
write("<img ID=\"mm1Tree\" src=\""+mimgpath+"/Tplus.gif\" align=\"absmiddle\" border=\"0\"><font ID=\"mTitle1\" onmouseover=\"mOver('mTitle1')\" onmouseout=\"mOut('mTitle1')\">文件</font></a>");
write("</div>");
write("<div ID=\"mm1Child\" style=\"display:none;\">");
write("<div ID=\"mm2Parent\"><a ID=\"mm2a\" target=\"_self\" href=\"#\" "+mfonts+" onClick=\"mFolderExpand('mm2',null,'0')\" title=\"\">");
write("<img src=\""+mimgpath+"/I.gif\" align=\"absmiddle\" width=\"19\" height=\"20\" border=\"0\"><img ID=\"mm2Tree\" src=\""+mimgpath+"/Tplus.gif\" align=\"absmiddle\" border=\"0\"><font ID=\"mTitle2\" onmouseover=\"mOver('mTitle2')\" onmouseout=\"mOut('mTitle2')\">新建</font></a>");
write("</div>");
write("<div ID=\"mm2Child\" style=\"display:none;\">");
write("<img src=\""+mimgpath+"/I.gif\" align=\"absmiddle\" width=\"19\" height=\"20\" border=\"0\"><img src=\""+mimgpath+"/I.gif\" align=\"absmiddle\" width=\"19\" height=\"20\" border=\"0\"><img src=\""+mimgpath+"/L.gif\" align=\"absmiddle\" width=\"19\" height=\"20\" border=\"0\"><a target=\"mainFrame\" href=\"main.htm\" "+mfonts+" title=\"\"><font ID=\"mTitle3\" onmouseover=\"mOver('mTitle3')\" onmouseout=\"mOut('mTitle3')\">新建文件</font></a><br/>");
write("</div>");
write("<img src=\""+mimgpath+"/I.gif\" align=\"absmiddle\" width=\"19\" height=\"20\" border=\"0\"><img src=\""+mimgpath+"/L.gif\" align=\"absmiddle\" width=\"19\" height=\"20\" border=\"0\"><a target=\"mainFrame\" href=\"main1.htm\" "+mfonts+" title=\"\"><font ID=\"mTitle4\" onmouseover=\"mOver('mTitle4')\" onmouseout=\"mOut('mTitle4')\">新建菜单</font></a><br/>");
write("</div>");
write("<img src=\""+mimgpath+"/L.gif\" align=\"absmiddle\" width=\"19\" height=\"20\" border=\"0\"><a target=\"_self\" href=\"#\" "+mfonts+" title=\"\"><font ID=\"mTitle5\" onmouseover=\"mOver('mTitle5')\" onmouseout=\"mOut('mTitle5')\">系统</font></a><br/>");
write("</div>");
}
这是用webmenushop做的
调用时只要在相应的页面上写上<script language="javascript" src="menu.js"></script>就可以了,当然还需要“+”号的图片前面的程序应该放在以menu.js为名字的文件中
<html>
<head>
<title>Untitled Document</title>
<Script Language="JavaScript">
//以下代码实现树
var strStyle='<style type="text/css">'
strStyle+='span.SelectIng{color:#ff00ff;border:solid 1pt #666666;padding:0.5pt;height:4px;background-color:#cccccc;}'
strStyle+='span.NoSelect{color:#000084;border:solid 1pt #ffffff;padding:0.5pt;height:4px;background-color:#ffffff;}'
strStyle+='span.SelectEd{color:#D02090;border:solid 1pt #888888;padding:0.5pt;height:4px;background-color:#f3f3f3;}'
strStyle+='</style>'
document.write(strStyle)var myRs=new Array(), selectItem;
function compare(a,b) {return parseInt(a[1]) - parseInt(b[1])}
function InsertItem(s){myRs[myRs.length++] = s.split(/,/);}function ExCloAll(n){
var d=document.all('0'), e=d.all.tags('div')
for (i=0;i<e.length;i++)e[i].style.display=(n==1?'block':'none')
e=d.all.tags('p')
for (i=0;i<e.length;i++){if(ChkExist(e[i].children[1].value))e[i].children[0].src=(n==1?'images/open.png':'images/close.png')}
}function ExCloItem(){
var c,e=event.srcElement, p=e.parentElement.children
if(e.myHref!=''){
eval((e.myTarget!=''?e.myTarget:'parent.mainFrame')+'.location.href='+'e.myHref') //要改成?接到某?只需把alert改成eval即可
}
window.status=e.innerText;
if(selectItem!=null)selectItem.className='NoSelect';
e.className='SelectEd'
selectItem=event.srcElement;
if(c=document.all(e.value)){
p[0].src=(c.style.display=='none'?'images/open.png':'images/close.png')
c.style.display=(c.style.display=='none'?'block':'none')
}else{p[0].src='images/window.gif'}
}
function ExCloItem2(){
var c,e=event.srcElement, p=e.parentElement.children
if(c=document.all(p[1].value)){
e.src=(c.style.display=='none'?'images/open.png':'images/close.png')
c.style.display=(c.style.display=='block'?'none':'block')
}else e.src='images/window.gif'
}function OutItem(){
var e=event.srcElement
if(selectItem != '')e.className=(selectItem==e?'SelectEd':'NoSelect')
else e.className='NoSelect'
}function ChkExist(n){
n=parseInt(n)
if((n<myRs[0][1])||(n>myRs[myRs.length-1][1]))return false
var a,b,c,x=0, y=parseInt(myRs.length/2), z=myRs.length-1
while((x!=y)&&(y!=z)){
a=myRs[x][1], b=myRs[y][1], c=myRs[z][1]
if(n==a||n==b||n==c)return true
if(n>b)x=y;
else z=y;y=parseInt(x+z);
y=parseInt((x+z)/2);
}
return false
}function drawTree(n){
if(n==0){
myRs.sort(compare)
document.write('<p style="font:10pt;cursor:hand;"><b><font color="#0099FF" size="2"><span onclick="ExCloAll(1)">展示全部模块</span><br><span onclick="ExCloAll(0)">关闭全部模块</span></font></b></p>')
}
if (ChkExist(n)!=true)return
document.write('<div id="'+n+'" style="font:10pt;cursor:hand;'+(n!=0?'position:relative;left:20;display:none;':'')+'">')
for(var i=0;i<myRs.length;i++){
//if (parseInt(myRs[i][1])>n)break;
if (myRs[i][1]==n){
document.write('<p style="margin:0pt;"><img src='+(ChkExist(myRs[i][0])?"images/close.png":"images/window.gif" )+' width="16" height="16" onclick="ExCloItem2()">')
document.write('<span onclick="ExCloItem()" myHref="'+(myRs[i].length>3?myRs[i][3]:'')+'" myTarget="' + (myRs[i].length>4?myRs[i][4]:'') +'" value="'+myRs[i][0]+'" class="NoSelect" onmouseout="OutItem()" onmouseover="this.className=\'SelectIng\'">'+myRs[i][2]+'</span></p>')
//if (myRs[i].length >3)document.write('</a>');
drawTree(myRs[i][0])
}
}
document.write('</div>')
}
InsertItem('1,0,生产计划,,');
InsertItem('2,0,库存管理,,');
InsertItem('3,0,生产操作费,,');
InsertItem('4,0,生产预警,,');
InsertItem('5,1,油产计划,,');
InsertItem('6,5,油产计划查询,oilplan.jsp,');
InsertItem('7,1,气产计划,,');
InsertItem('8,2,油库存查询,http://www.sina.com.cn,');
InsertItem('9,2,副产品库存,,');
InsertItem('10,9,LPG,LPG.jsp,');
InsertItem('11,9,戊烷,戊烷.jsp,');
InsertItem('12,9,轻烃,轻烃.jsp,');
InsertItem('13,7,干气,,');
InsertItem('14,13,干气查询,,');
InsertItem('15,14,查询例子集,,');
InsertItem('16,15,查询例子,example.jsp,');InsertItem('17,4,生产预警1,,');
InsertItem('18,3,搜狐,http://www.sohu.com,');
InsertItem('19,3,不同发布项目测试,http://olapsvr/Project1/test.jsp,');
drawTree(0)
</Script></head><body bgcolor="#FFFFFF" text="#000000"></body>
</html>
去下吧,asp+access,完美树结构