请孟子E章大哥进来一下!

treemenu2 2003-06-14 05:33:19
我用了你的一个菜单,但是修改不成功,你可不可以帮我改一下,拜托了!
你那个是实现框架的,而我不想实现框架的!

代码如下:
<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<META http-equiv="The JavaScript Source" content=no-cache>

<SCRIPT language=JavaScript>
function generateTree()
{
var aux1, aux2, aux3, aux4
foldersTree = folderNode("根:单击这里开始展开")
aux1 = appendChild(foldersTree, folderNode("第一级目录A"))
aux2 = appendChild(aux1, leafNode("第二级目录A1"))
appendChild(aux2, generateDocEntry(0, "第二级文件A1_1", "http://lucky.myrice.com/",""))

aux1 = appendChild(foldersTree, folderNode("第一级目录B"))
aux2 = appendChild(aux1, leafNode("第二级目录B1"))
appendChild(aux2, generateDocEntry(0, "第二级文件1", "http://lucky.myrice.com/", ""))
}


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 = "<img src='doc.gif' alt='Opens in right frame'"
else
retString = "<img src='link.gif' alt='Opens in new window'"

retString = retString + " border=0><td nowrap><font style='font-family:宋体;font-size:9pt'><a target=folderFrame href='" + link + "'>" + docDescription + "</a></font>"

return retString
}

function redrawTree()
{
var doc =document
doc.clear()
doc.write("<body bgcolor='white'><style>a,td {line-height:11pt}</style>")
redrawNode(foldersTree, doc, 0, 1, "")
doc.write("</body>")
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)
{
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:openBranch(\"" + foldersNode[3] + "\")'")
if (foldersNode[1])
{
doc.write("onMouseOver='window.status=\"Close folder\"; return true'><img src=")
doc.write("openfolder.gif width=24 height=22 border=noborder></a>")
}
else
{
doc.write("onMouseOver='window.status=\"Open folder\"; return true'><img src=")
doc.write("closedfolder.gif width=24 height=22 border=noborder></a>")
}
doc.write("<td valign=middle align=left nowrap>")
doc.write("<font style='font-family:宋体;line-height:9pt;font-size:9pt'><a href='javascript:openBranch(\"" + foldersNode[3] + "\")'>"+foldersNode[3]+"</a></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=="根:单击这里开始展开" && foldersTree[0]==0)
// folderFrame.location="http://lucky.myrice.com/"
timeOutId = setTimeout("redrawTree()",100)
}

function initializeTree()
{
generateTree()
redrawTree()
}
var foldersTree = 0
var timeOutId = 0
generateTree()
</SCRIPT>


<META content="MSHTML 6.00.2600.0" name=GENERATOR></HEAD>
<script>
initializeTree()
</script>


...全文
19 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
treemenu2 2003-06-15
  • 打赏
  • 举报
回复
我不知道说什么好,总之
"非常感激"就是了!

孟子E章 2003-06-15
  • 打赏
  • 举报
回复
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<script>
imageDir = "";
/** 文件节点的图片 */
img_file = imageDir+"file.gif";
/** 关闭的目录的图片 */
img_folder_close = imageDir+"close.gif";
/** 在中间的加号的图片 */
img_plus = imageDir+"plusnode.gif";
/** 在树末尾的加号的图片 */
img_plus_last = imageDir+"pluslastnode.gif";
/** 打开的目录的图片 */
img_folder_open = imageDir+"open.gif";
/** 在树末尾的减号的图片 */
img_minus_last = imageDir+"minuslastnode.gif";
/** 在中间的减号的图片 */
img_minus = imageDir+"minusnode.gif";
/** 无节点线条的图片 */
img_line = imageDir+"line.gif";
/** 最后节点的线条图片 */
img_line_last = imageDir+"lastnode.gif";
/** 中间节点的线条图片 */
img_line_mid = imageDir+"node.gif";
/** 空白区域的图片 */
img_blank = imageDir+"blank.gif";


function tree(){

/** 根节点 */
this.root = null;
/** 节点个数 */
this.length = 0;
/** 节点数组 */
this.nodes = new Array();
/** 在drawFrontLine时用来临时存储字符串 */
this.tempStr = "";

/** 添加根节点 */
this.addRoot = addRoot;
/** 添加节点 */
this.addNode = addNode;

/** 画出根节点 */
this.drawRoot = drawRoot;
/** 画出节点前的空白图片或连接线图片 */
this.drawFrontLine = drawFrontLine;
/** 画出节点 */
this.drawNode = drawNode;
/** 画出所有节点 */
this.drawNodes = drawNodes;
/** 得到节点的父节点 */
this.getParent = getParent;
/** 添加节点时,将同一层的其他节点的isLast属性设置为false */
this.setOtherIsLast = setOtherIsLast;
}

/**
* 根节点对象
* @param id 根节点的id号
* @param name 根节点名称,显示在页面的连接的名字
* @param url 链接
* @param target 指示链接的目标页面
*/
function root(id,name,url,target) {
this.id = id;
this.name = name;
this.parentId = null;
this.type = "root";
this.url = url;
this.target = target;
}

function addRoot(root) {
this.root = root;
this.length = 1;
this.nodes[0] = root;
}

/**
* 节点对象
* @param id 节点id号
* @param name 节点名称,显示在页面上的链接的名字
* @param parentId 父节点id号
* @param type 节点的类型(folder|file)
* @param url 节点的链接
* @param target 节点链接的目标页面
*/

function node(id,name,parentId,type,url,target) {
/** 节点id号 */
this.id = id;
/** 节点名称,显示在页面上的链接的名字 */
this.name =name;
/** 父节点id号 */
this.parentId = parentId;
/** 节点的类型(folder|file) */
this.type = type;
/** 节点的链接 */
this.url = url;
/** 节点链接的目标页面 */
this.target = target;


/** 节点的图片(目录或文件等) */
this.image = "";
/** 节点的前导图片(加号或减号或线条等) */
this.fImage = "";
/** 是否是同层中最后节点 */
this.isLast = false;
}

/** 判断一个节点是否有父节点,如果有则返回其父节点,如果没有返回null */
function getParent(node) {
for (var i=0;i<this.length;i++)
{
if (this.nodes[i].id == node.parentId)
{
return this.nodes[i];
}
}
return null;
}

/** 当添加一个新节点后,将与它处在同一层的其它元素的isLast标志设置为false */
function setOtherIsLast(node) {
for (var i=1;i<this.length;i++) //i=1,表示不包括根节点在内的循环
{
if (this.nodes[i].parentId == node.parentId && this.nodes[i].isLast) //如果找到父节点相同的,并且isLast为true的节点
{
this.nodes[i].isLast = false; //设置该节点的isLast为false
if (this.nodes[i].type == "folder") //设置图片为非末节点图片
{
this.nodes[i].fImage = img_plus;
} else {
this.nodes[i].fImage = img_line_mid;
}
return true;
}
}
return false;
}

/** 为树的节点组nodes[]添加一个新的节点 */
function addNode(node) {
if (this.getParent(node) != null) //如果有父节点
{
this.setOtherIsLast(node); //设置同层中的其他元素为非末节点
node.isLast = true; //设置本节点为末节点
if (node.type == "folder") //根据节点类型设置图片
{
node.image = img_folder_close;
node.fImage = img_plus_last;
} else {
node.image = img_file;
node.fImage = img_line_last;
}
this.nodes[this.length] = node; //添加该节点到树的节点组nodes[]
this.length++; //节点数加1
} else {
alert("没有找到该节点的父节点,这是一个非法节点!");
}
}
/** 画出根节点 */
function drawRoot() {
document.write("<table border='0' cellspacing='0' cellpadding='0'>");
document.write("<tr style='font-size:12px'><td>");
document.write("<a onFocus='this.blur()' href='"+this.root.url+"' target='"+this.root.target+"'><img border='0' src='"+img_folder_close+"'></a>");
document.write("</td><td valign='middle'>");
document.write("<a onFocus='this.blur()' href='"+this.root.url+"' target='"+this.root.target+"'>"+this.root.name+"</a>");
document.write("</td></tr>");
document.write("</table>");
}

/** 画出节点 */
function drawNode(node) {
document.write("<table border='0' cellspacing='0' cellpadding='0'>");
document.write("<tr style='font-size:12px'><td>");
this.drawFrontLine(node);
if (node.type == "folder")
{
document.write("<a onClick='clickOnFolder()' onFocus='this.blur()' href='#'><img border='0' src='"+node.fImage+"'></a>");
document.write("<a onFocus='this.blur()' href='"+node.url+"' target='"+node.target+"'><img border='0' src='"+node.image+"'></a>");
document.write("</td><td valign='middle'>");
document.write("<a onFocus='this.blur()' id='folderLink' href='"+node.url+"' target='"+node.target+"'>"+node.name+"</a>");
} else {
document.write("<img border='0' src='"+node.fImage+"'>");
document.write("<a onFocus='this.blur()' href='"+node.url+"' target='"+node.target+"'><img border='0' src='"+node.image+"'></a>");
document.write("</td><td valign='middle'>");
document.write("<a onFocus='this.blur()' href='"+node.url+"' target='"+node.target+"'>"+node.name+"</a>");
}
document.write("</td></tr>");
document.write("</table>");
}

孟子E章 2003-06-15
  • 打赏
  • 举报
回复
哈,有时间帮呢该下
孟子E章 2003-06-15
  • 打赏
  • 举报
回复
http://xml.sz.luohuedu.net/CoolMenu/main.htm
treemenu2 2003-06-14
  • 打赏
  • 举报
回复
帮帮我吧!

87,907

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧