文件:menu.js,只要在要使用的网页上的相应的位置加上代码:
<script language="javascript" src="menu.js"></script>
menu.js:
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+"/white.gif"; }
else { ExpandTree.src = mimgpath+"/white.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+"/white.gif"; }
else { ExpandTree.src = mimgpath+"/white.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+"/white.gif"; }
else { ExpandTree.src = mimgpath+"/white.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+"/white.gif"; }
else { ExpandTree.src = mimgpath+"/white.gif"; }
//ExpandFolder.src = mimgpath+"/folder"+pic+".gif";
}
else {document.getElementById("mmTree").src = mimgpath+"/top1.gif"; }
}
}
with(document){
write("<div ID=\"mmChild\"><div ID=\"mm1Parent\"><a ID=\"mm1a\" target=\"_self\" href=\"#\" "+mfonts+" onClick=\"mFolderExpand('mm1',null,'0')\" title=\"\">");
write("<img ID=\"mm1Tree\" src=\""+mimgpath+"/white.gif\" align=\"absmiddle\" border=\"0\"><font ID=\"mTitle1\" onmouseover=\"mOver('mTitle1')\" onmouseout=\"mOut('mTitle1')\">A</font></a>");
write("</div>");
write("<div ID=\"mm1Child\" style=\"display:none;\">");
write("<img src=\""+mimgpath+"/white.gif\" align=\"absmiddle\" width=\"19\" height=\"20\" border=\"0\"><img src=\""+mimgpath+"/white.gif\" align=\"absmiddle\" width=\"19\" height=\"20\" border=\"0\"><a target=\"_self\" href=\"A.ASP\" "+mfonts+" title=\"\"><font ID=\"mTitle2\" onmouseover=\"mOver('mTitle2')\" onmouseout=\"mOut('mTitle2')\">A1</font></a><br>");
write("<img src=\""+mimgpath+"/white.gif\" align=\"absmiddle\" width=\"19\" height=\"20\" border=\"0\"><img src=\""+mimgpath+"/white.gif\" align=\"absmiddle\" width=\"19\" height=\"20\" border=\"0\"><a target=\"_self\" href=\"B.ASP\" "+mfonts+" title=\"\"><font ID=\"mTitle3\" onmouseover=\"mOver('mTitle3')\" onmouseout=\"mOut('mTitle3')\">A2</font></a><br>");
write("<img src=\""+mimgpath+"/white.gif\" align=\"absmiddle\" width=\"19\" height=\"20\" border=\"0\"><img src=\""+mimgpath+"/white.gif\" align=\"absmiddle\" width=\"19\" height=\"20\" border=\"0\"><a target=\"_self\" href=\"C.ASP\" "+mfonts+" title=\"\"><font ID=\"mTitle4\" onmouseover=\"mOver('mTitle4')\" onmouseout=\"mOut('mTitle4')\">A3</font></a><br>");
write("</div>");
write("<div ID=\"mm2Parent\"><a ID=\"mm2a\" target=\"_self\" href=\"#\" "+mfonts+" onClick=\"mFolderExpand('mm2',null,'0')\" title=\"\">");
write("<img ID=\"mm2Tree\" src=\""+mimgpath+"/white.gif\" align=\"absmiddle\" border=\"0\"><font ID=\"mTitle5\" onmouseover=\"mOver('mTitle5')\" onmouseout=\"mOut('mTitle5')\">B</font></a>");
write("</div>");
write("<div ID=\"mm2Child\" style=\"display:none;\">");
write("<img src=\""+mimgpath+"/white.gif\" align=\"absmiddle\" width=\"19\" height=\"20\" border=\"0\"><img src=\""+mimgpath+"/white.gif\" align=\"absmiddle\" width=\"19\" height=\"20\" border=\"0\"><a target=\"_self\" href=\"A.ASP\" "+mfonts+" title=\"\"><font ID=\"mTitle6\" onmouseover=\"mOver('mTitle6')\" onmouseout=\"mOut('mTitle6')\">B1</font></a><br>");
write("<img src=\""+mimgpath+"/white.gif\" align=\"absmiddle\" width=\"19\" height=\"20\" border=\"0\"><img src=\""+mimgpath+"/white.gif\" align=\"absmiddle\" width=\"19\" height=\"20\" border=\"0\"><a target=\"_self\" href=\"B.ASP\" "+mfonts+" title=\"\"><font ID=\"mTitle7\" onmouseover=\"mOver('mTitle7')\" onmouseout=\"mOut('mTitle7')\">B2</font></a><br>");
write("<img src=\""+mimgpath+"/white.gif\" align=\"absmiddle\" width=\"19\" height=\"20\" border=\"0\"><img src=\""+mimgpath+"/white.gif\" align=\"absmiddle\" width=\"19\" height=\"20\" border=\"0\"><a target=\"_self\" href=\"C.ASP\" "+mfonts+" title=\"\"><font ID=\"mTitle8\" onmouseover=\"mOver('mTitle8')\" onmouseout=\"mOut('mTitle8')\">B3</font></a><br>");
write("</div>");
write("<div ID=\"mm3Parent\"><a ID=\"mm3a\" target=\"_self\" href=\"#\" "+mfonts+" onClick=\"mFolderExpand('mm3','last','0')\" title=\"\">");
write("<img ID=\"mm3Tree\" src=\""+mimgpath+"/white.gif\" align=\"absmiddle\" border=\"0\"><font ID=\"mTitle9\" onmouseover=\"mOver('mTitle9')\" onmouseout=\"mOut('mTitle9')\">C</font></a>");
write("</div>");
write("<div ID=\"mm3Child\" style=\"display:none;\">");
write("<img src=\""+mimgpath+"/white.gif\" align=\"absmiddle\" width=\"19\" height=\"20\" border=\"0\"><img src=\""+mimgpath+"/white.gif\" align=\"absmiddle\" width=\"19\" height=\"20\" border=\"0\"><a target=\"_self\" href=\"A.ASP\" "+mfonts+" title=\"\"><font ID=\"mTitle10\" onmouseover=\"mOver('mTitle10')\" onmouseout=\"mOut('mTitle10')\">C1</font></a><br>");
write("<img src=\""+mimgpath+"/white.gif\" align=\"absmiddle\" width=\"19\" height=\"20\" border=\"0\"><img src=\""+mimgpath+"/white.gif\" align=\"absmiddle\" width=\"19\" height=\"20\" border=\"0\"><a target=\"_self\" href=\"B.ASP\" "+mfonts+" title=\"\"><font ID=\"mTitle11\" onmouseover=\"mOver('mTitle11')\" onmouseout=\"mOut('mTitle11')\">C2</font></a><br>");
write("<img src=\""+mimgpath+"/white.gif\" align=\"absmiddle\" width=\"19\" height=\"20\" border=\"0\"><img src=\""+mimgpath+"/white.gif\" align=\"absmiddle\" width=\"19\" height=\"20\" border=\"0\"><a target=\"_self\" href=\"C.ASP\" "+mfonts+" title=\"\"><font ID=\"mTitle12\" onmouseover=\"mOver('mTitle12')\" onmouseout=\"mOut('mTitle12')\">C3</font></a><br>");
write("</div>");
write("</div>");
}
<script language="javascript" src="menu.js"></script>
menu.js:
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+"/white.gif"; }
else { ExpandTree.src = mimgpath+"/white.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+"/white.gif"; }
else { ExpandTree.src = mimgpath+"/white.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+"/white.gif"; }
else { ExpandTree.src = mimgpath+"/white.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+"/white.gif"; }
else { ExpandTree.src = mimgpath+"/white.gif"; }
//ExpandFolder.src = mimgpath+"/folder"+pic+".gif";
}
else {document.getElementById("mmTree").src = mimgpath+"/top1.gif"; }
}
}
with(document){
write("<div ID=\"mmChild\"><div ID=\"mm1Parent\"><a ID=\"mm1a\" target=\"_self\" href=\"#\" "+mfonts+" onClick=\"mFolderExpand('mm1',null,'0')\" title=\"\">");
write("<img ID=\"mm1Tree\" src=\""+mimgpath+"/white.gif\" align=\"absmiddle\" border=\"0\"><font ID=\"mTitle1\" onmouseover=\"mOver('mTitle1')\" onmouseout=\"mOut('mTitle1')\">A</font></a>");
write("</div>");
write("<div ID=\"mm1Child\" style=\"display:none;\">");
write("<img src=\""+mimgpath+"/white.gif\" align=\"absmiddle\" width=\"19\" height=\"20\" border=\"0\"><img src=\""+mimgpath+"/white.gif\" align=\"absmiddle\" width=\"19\" height=\"20\" border=\"0\"><a target=\"_self\" href=\"A.ASP\" "+mfonts+" title=\"\"><font ID=\"mTitle2\" onmouseover=\"mOver('mTitle2')\" onmouseout=\"mOut('mTitle2')\">A1</font></a><br>");
write("<img src=\""+mimgpath+"/white.gif\" align=\"absmiddle\" width=\"19\" height=\"20\" border=\"0\"><img src=\""+mimgpath+"/white.gif\" align=\"absmiddle\" width=\"19\" height=\"20\" border=\"0\"><a target=\"_self\" href=\"B.ASP\" "+mfonts+" title=\"\"><font ID=\"mTitle3\" onmouseover=\"mOver('mTitle3')\" onmouseout=\"mOut('mTitle3')\">A2</font></a><br>");
write("<img src=\""+mimgpath+"/white.gif\" align=\"absmiddle\" width=\"19\" height=\"20\" border=\"0\"><img src=\""+mimgpath+"/white.gif\" align=\"absmiddle\" width=\"19\" height=\"20\" border=\"0\"><a target=\"_self\" href=\"C.ASP\" "+mfonts+" title=\"\"><font ID=\"mTitle4\" onmouseover=\"mOver('mTitle4')\" onmouseout=\"mOut('mTitle4')\">A3</font></a><br>");
write("</div>");
write("<div ID=\"mm2Parent\"><a ID=\"mm2a\" target=\"_self\" href=\"#\" "+mfonts+" onClick=\"mFolderExpand('mm2',null,'0')\" title=\"\">");
write("<img ID=\"mm2Tree\" src=\""+mimgpath+"/white.gif\" align=\"absmiddle\" border=\"0\"><font ID=\"mTitle5\" onmouseover=\"mOver('mTitle5')\" onmouseout=\"mOut('mTitle5')\">B</font></a>");
write("</div>");
write("<div ID=\"mm2Child\" style=\"display:none;\">");
write("<img src=\""+mimgpath+"/white.gif\" align=\"absmiddle\" width=\"19\" height=\"20\" border=\"0\"><img src=\""+mimgpath+"/white.gif\" align=\"absmiddle\" width=\"19\" height=\"20\" border=\"0\"><a target=\"_self\" href=\"A.ASP\" "+mfonts+" title=\"\"><font ID=\"mTitle6\" onmouseover=\"mOver('mTitle6')\" onmouseout=\"mOut('mTitle6')\">B1</font></a><br>");
write("<img src=\""+mimgpath+"/white.gif\" align=\"absmiddle\" width=\"19\" height=\"20\" border=\"0\"><img src=\""+mimgpath+"/white.gif\" align=\"absmiddle\" width=\"19\" height=\"20\" border=\"0\"><a target=\"_self\" href=\"B.ASP\" "+mfonts+" title=\"\"><font ID=\"mTitle7\" onmouseover=\"mOver('mTitle7')\" onmouseout=\"mOut('mTitle7')\">B2</font></a><br>");
write("<img src=\""+mimgpath+"/white.gif\" align=\"absmiddle\" width=\"19\" height=\"20\" border=\"0\"><img src=\""+mimgpath+"/white.gif\" align=\"absmiddle\" width=\"19\" height=\"20\" border=\"0\"><a target=\"_self\" href=\"C.ASP\" "+mfonts+" title=\"\"><font ID=\"mTitle8\" onmouseover=\"mOver('mTitle8')\" onmouseout=\"mOut('mTitle8')\">B3</font></a><br>");
write("</div>");
write("<div ID=\"mm3Parent\"><a ID=\"mm3a\" target=\"_self\" href=\"#\" "+mfonts+" onClick=\"mFolderExpand('mm3','last','0')\" title=\"\">");
write("<img ID=\"mm3Tree\" src=\""+mimgpath+"/white.gif\" align=\"absmiddle\" border=\"0\"><font ID=\"mTitle9\" onmouseover=\"mOver('mTitle9')\" onmouseout=\"mOut('mTitle9')\">C</font></a>");
write("</div>");
write("<div ID=\"mm3Child\" style=\"display:none;\">");
write("<img src=\""+mimgpath+"/white.gif\" align=\"absmiddle\" width=\"19\" height=\"20\" border=\"0\"><img src=\""+mimgpath+"/white.gif\" align=\"absmiddle\" width=\"19\" height=\"20\" border=\"0\"><a target=\"_self\" href=\"A.ASP\" "+mfonts+" title=\"\"><font ID=\"mTitle10\" onmouseover=\"mOver('mTitle10')\" onmouseout=\"mOut('mTitle10')\">C1</font></a><br>");
write("<img src=\""+mimgpath+"/white.gif\" align=\"absmiddle\" width=\"19\" height=\"20\" border=\"0\"><img src=\""+mimgpath+"/white.gif\" align=\"absmiddle\" width=\"19\" height=\"20\" border=\"0\"><a target=\"_self\" href=\"B.ASP\" "+mfonts+" title=\"\"><font ID=\"mTitle11\" onmouseover=\"mOver('mTitle11')\" onmouseout=\"mOut('mTitle11')\">C2</font></a><br>");
write("<img src=\""+mimgpath+"/white.gif\" align=\"absmiddle\" width=\"19\" height=\"20\" border=\"0\"><img src=\""+mimgpath+"/white.gif\" align=\"absmiddle\" width=\"19\" height=\"20\" border=\"0\"><a target=\"_self\" href=\"C.ASP\" "+mfonts+" title=\"\"><font ID=\"mTitle12\" onmouseover=\"mOver('mTitle12')\" onmouseout=\"mOut('mTitle12')\">C3</font></a><br>");
write("</div>");
write("</div>");
}
解决方案 »
- aa.innerHTML='里面js代码不能执行';
- alert确定以后再跳转url
- 网页上面的tab框通常是怎样做的啊,如新浪上面常见的哪些,要兼容ie和google等
- 关于javascript控制播放器的问题
- window.top.location.replace 的问题
- 如何在页面中隐藏一个text,但是当点击一个按钮时再显示这个text,如同163的附件按钮 点击附件按钮的时候才出现浏览和上传的东东
- 如何取IE浏览器的窗口的位置与大小?非body的位置与大小,也不是屏幕的分辨率
- 着急回家呢,帮忙解决个问题!
- 请大家帮忙解决一下!!!谢谢啦..
- echarts
- 请问如何用javascript校验E-MAIL中@字符前面的中文名称?
- 图片如何在同一个位置叠加(窗口大小改变后,位置没有相对变化)?急
http://expert.csdn.net/Expert/TopicView1.asp?id=1537094
http://www.iecn.net/forum/showthread.php?threadid=785
你要的树可以这样生成了:
tree=new alai_tree()
root=tree.root
A=root.add("A")
A.addLink("a.asp","A1")
A.addLink("b.asp","A2")
....是不是很方便?