treedir.js

来自「电子派单系统」· JavaScript 代码 · 共 113 行

JS
113
字号
function limg_onclick(li, d, limg) 
{ 
if(d.style.display == "none") 
{ 
d.style.display = "block" 
limg.src = "open.gif" 
} 
else 
{ 
d.style.display = "none" 
limg.src = "closed.gif" 
} 
window.event.cancelBubble = true 
} 

function li_onclick(li, d, limg) 
{ 
if(d == null) 
{ 
alert("You click " + window.event.srcElement.id + "!") 
} 
else 
{ 
if(d.style.display == "none") 
{ 
d.style.display = "block" 
limg.src = "open.gif" 
} 
else 
{ 
d.style.display = "none" 
limg.src = "closed.gif" 
} 
} 
window.event.cancelBubble = true 
} 

function li_onmouseover(li) 
{ 
li.style.color = itemAFC 
li.style.backgroundColor = itemABC 
window.event.cancelBubble = true 
} 

function li_onmouseout(li) 
{ 
li.style.color = itemFC 
li.style.backgroundColor = treeBC 
window.event.cancelBubble = true 
} 

function writeItem(li, suffix) 
{ 
if(li.toString().split(",").length == 1) 
{ 
var str = li.split(";") 
document.write("<IMG id=limg" + suffix + " SRC=\"doc.gif\">&nbsp;<SPAN id=li" + suffix) 
document.write(" style=\"COLOR: " + itemFC + "; CURSOR: hand;\"") 
document.write(" LANGUAGE=javascript") 

document.write(" onmouseover=\"return li_onmouseover(li" + suffix + ")\"") 
document.write(" onmouseout=\"return li_onmouseout(li" + suffix + ")\">") 
if(str.length >= 2) 
{ 
document.write("<A target=\"" + treeTarget + "\" HREF=\"" + str[1] + "\">" + str[0] + "</A></SPAN><BR>") 
} 
else 
{ 
document.write(str[0] + "</SPAN><BR>") 
} 
} 
else 
{ 
document.write("<IMG id=limg" + suffix + " SRC=\"closed.gif\"") 
document.write(" style=\"COLOR: " + itemFC + "; CURSOR: hand;\"") 
document.write(" LANGUAGE=javascript") 
document.write(" onclick =\"return limg_onclick(li" + suffix + ", d" 
+ suffix + ", limg" + suffix + ")\"") 
document.write(">&nbsp;<SPAN id=li" + suffix) 

document.write(" style=\"COLOR: black; CURSOR: hand;\"") 
document.write(" LANGUAGE=javascript") 
document.write(" onclick =\"return li_onclick(li" + suffix + ", d" 
+ suffix + ", limg" + suffix + ")\"") 
document.write(" onmouseover=\"return li_onmouseover(li" + suffix + ")\"") 
document.write(" onmouseout=\"return li_onmouseout(li" + suffix + ")\">") 
document.write(li[0] + "</SPAN><BR>") 
document.write("<DIV id=d" + suffix + " style=\"DISPLAY: none\">") 
document.write("<UL id=u" + suffix + " style=\"MARGIN-LEFT: " + indent + "\">") 
for(var i = 1; i < li.length; i++) 
{ 
writeItem(li[i], suffix + "_" + i) 
} 
document.write("</UL></DIV>") 
} 
} 


var treeBC = "lightblue" 
var treeFC = "darkblue" 
var itemFC = "black" 
var itemABC = "lightskyblue" 
var itemAFC = "red" 
var indent = 12 
var marginleft = 2 
var treeTarget = "main" 

var li = new Array() 
li[0] = "总目录" 
li[1] = new Array() 


⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?