主题:这个功能应该把tree menu怎样修改才能实现?
wendyxia
[专家分:0] 发布于 2006-09-29 17:17:00
网页用frame结构,leftframe调用tree menu 的javascript脚本构造句一个菜单。
我现在每个菜单选项点击时,链接网页显示在leftframe中。
我的目的是,点击每个菜单选项时相应链接的webpage显示在右边的frame中,即显示在mainframe中。
请问如何修改 tree.js 加入 target="mainFrame" ,使之功能实现 ?
回复列表 (共1个回复)
沙发
wendyxia [专家分:0] 发布于 2006-09-29 17:18:00
tree.js 代码
======================
/**************************************************************************
Copyright (c) 2001-2003 Geir Landr?(drop@destroydrop.com)
JavaScript Tree - www.destroydrop.com/hjavascripts/tree/
Version 0.96
This script can be used freely as long as all copyright messages are
intact.
**************************************************************************/
// Arrays for nodes and icons
var nodes = new Array();;
var openNodes = new Array();
var icons = new Array(6);
// Loads all icons that are used in the tree
function preloadIcons() {
icons[0] = new Image();
icons[0].src = "img/plus.gif";
icons[1] = new Image();
icons[1].src = "img/plusbottom.gif";
icons[2] = new Image();
icons[2].src = "img/minus.gif";
icons[3] = new Image();
icons[3].src = "img/minusbottom.gif";
icons[4] = new Image();
icons[4].src = "img/folder.gif";
icons[5] = new Image();
icons[5].src = "img/folderopen.gif";
}
// Create the tree
function createTree(arrName, startNode, openNode) {
nodes = arrName;
if (nodes.length > 0) {
preloadIcons();
if (startNode == null) startNode = 0;
if (openNode != 0 || openNode != null) setOpenNodes(openNode);
if (startNode !=0) {
var nodeValues = nodes[getArrayId(startNode)].split("|");
document.write("<a href=\"" + nodeValues[3] + "\" onmouseover=\"window.status='" + nodeValues[2] + "';return true;\" onmouseout=\"window.status=' ';return true;\"><img src=\"img/folderopen.gif\" align=\"absbottom\" alt=\"\" />" + nodeValues[2] + "</a><br />");
} else document.write("<img src=\"img/base.gif\" align=\"absbottom\" alt=\"\" />Website<br />");
var recursedNodes = new Array();
addNode(startNode, recursedNodes);
}
}
// Returns the position of a node in the array
function getArrayId(node) {
for (i=0; i<nodes.length; i++) {
var nodeValues = nodes.split("|");
if (nodeValues[0]==node) return i;
}
}
// Puts in array nodes that will be open
function setOpenNodes(openNode) {
for (i=0; i<nodes.length; i++) {
var nodeValues = nodes.split("|");
if (nodeValues[0]==openNode) {
openNodes.push(nodeValues[0]);
setOpenNodes(nodeValues[1]);
}
}
}
// Checks if a node is open
function isNodeOpen(node) {
for (i=0; i<openNodes.length; i++)
if (openNodes==node) return true;
return false;
}
我来回复