呵呵,又给我碰到了(抄的):
主函数部分:
var items = new Array();
// array of all items in the sitemap
var topItems = new Array();
// top level items only
var browser = "OTHER";
// browser version (IE, NS or OTHER)
var selectedItem = null;
// current selected item
var style = null;
// site map style
var scriptURL = null;
// URL to the script folder
var expandTopItems = null;
// true to expand top level items
var mouseOverColor = null;
// mouse over color
var selectedColor = null;
// selected color
var selectedBackground = null;
// selected background color
function adjustY()
{
if ( browser != "NS" )
return;
var y = 0;
var minWidth = 0;
var minHeight = 0;
for ( var i=0;
i<items.length;
i++ )
{
items.obj.top = y;
items.obj.left = 0;
if ( items.obj.visibility == "show" )
{
y += items.obj.clip.height;
if ( items.obj.clip.width > minWidth )
minWidth = items.obj.clip.width;
minHeight += items.obj.clip.height;
}
}
do
cument.sitemap.clip.right = minWidth;
do
cument.sitemap.clip.bottom = minHeight;
}
function colapse( siteItem )
{
if ( selectedItem == siteItem )
selectItem( null );
for ( var i=0;
i<siteItem.children.length;
i++ )
{
if ( browser == "IE" )
siteItem.children.obj.style.display = "none";
else
siteItem.children.obj.visibility = "hide";
colapse( siteItem.children );
}
}
function display()
{
if ( browser == "IE" )
_writeln( "<table border='0' cellspacing='0' cellpadding='0' class='chn'><tr><td valign=top align=left class='chn'>" );
for ( var i=0;
i<topItems.length;
i++ )
renderItem( topItems, "" );
if ( browser == "IE" )
_writeln( "</td></tr></table>" );
else
if ( browser == "NS" )
window.onResize = restoreIcons;
else
return;
for ( var i=0;
i<topItems.length;
i++ )
{
var siteItem = topItems;
if ( browser == "IE" )
siteItem.obj.style.display = "block";
else
if ( browser == "NS" )
siteItem.obj.visibility = "show";
if ( (expandTopItems) &&
(siteItem.children.length != 0) )
{
expand( siteItem );
siteItem.opened = true;
updateIcons( siteItem );
}
}
adjustY();
}
function expand( siteItem )
{
for ( var i=0;
i<siteItem.children.length;
i++ )
{
if ( browser == "IE" )
siteItem.children.obj.style.display = "block";
else
siteItem.children.obj.visibility = "show";
if ( siteItem.children.opened )
expand( siteItem.children );
}
}
function expandColapse( siteItem )
{
var children;
if ( siteItem.parent == null )
if ( expandTopItems )
{
expand( siteItem );
return;
}
else
children = topItems;
else
children = siteItem.parent.children;
for ( var i=0;
i<children.length;
i++ )
if ( (children.opened) &&
(children != siteItem) )
{
children.opened = false;
colapse( children );
updateIcons( children );
}
expand( siteItem );
}
function getTreeIcon( siteItem )
{
var icon;
if ( siteItem.children.length == 0 )
if ( style == "OUTLINE" )
icon = "blank.gif";
else
if ( siteItem.last )
icon = "simplel.gif";
else
icon = "simple.gif";
else
if ( siteItem.opened )
if ( style == "OUTLINE" )
icon = "minus.gif";
else
if ( siteItem.last )
icon = "colapsel.gif";
else
icon = "colapse.gif";
else
if ( style == "OUTLINE" )
icon = "plus.gif";
else
if ( siteItem.last )
icon = "expandl.gif";
else
icon = "expand.gif";
return scriptURL+icon;
}
function itemClicked( siteItem )
{
if ( (siteItem.children.length != 0) &&
(browser != "OTHER") )
{
siteItem.opened = !siteItem.opened;
if ( siteItem.opened )
expandColapse( siteItem );
else
colapse( siteItem );
}
selectItem( siteItem );
adjustY();
}
function itemMouseOut( siteItem )
{
siteItem.mouseOver = false;
if ( (siteItem.style != null) &&
(!siteItem.selected) )
siteItem.style.color = "";
updateIcons( siteItem );
adjustY();
}
function itemMouseOver( siteItem )
{
siteItem.mouseOver = true;
if ( (siteItem.style != null) &&
(!siteItem.selected) )
siteItem.style.color = mouseOverColor;
updateIcons( siteItem );
adjustY();
var message = "";
if ( siteItem.message != null )
message = siteItem.message;
else
if ( siteItem.url != null )
message = siteItem.url;
return message;
}
function outputItemAnchor( siteItem, element )
{
_write( "<td nowrap>" );
if ( siteItem.url == null )
_write( "<a href='javascript:itemClicked(items["+siteItem.id+"])'" );
else
{
_write( "<a href='"+siteItem.url+"'" );
if ( siteItem.target != null )
_write( " target='"+siteItem.target+"'" );
_write( " onClick='itemClicked(items["+siteItem.id+"])'" );
}
_write( " onMouseOver='window.status=itemMouseOver(items["+siteItem.id+"]);
return true'" );
_write( " onMouseOut='itemMouseOut(items["+siteItem.id+"]);
window.status=/"/";
return true'" );
_write( "class='chn'>" );
_write( element );
_write( "</a>" );
_write( "</td>" );
}
function renderItem( siteItem, left )
{
if ( browser == "IE" )
_write( "<table border='0' cellspacing='0' cellpadding='0' id='item"+siteItem.id+"' style='position:relative;display:none' width='100%' class='chn'>" );
else
if ( browser == "NS" )
{
_write( "<layer id='item"+siteItem.id+"' position='relative' visibility='hide' class='chn'>" );
_write( "<table border='0' cellspacing='0' cellpadding='0' width='100%' class='chn'>" );
}
else
_write( "<table border='0' cellspacing='0' cellpadding='0' width='100%' class='chn'>" );
_write( "<tr align=left valign=middle class='chn'>" );
_write( left );
if ( style != "LIST" )
{
if ( siteItem.children.length > 0 )
_write( "<td class='chn'><a href='javascript:treeIconClicked(items["+siteItem.id+"])' onMouseOver='window.status=/"/";
return true'><img name='treeIcon"+siteItem.id+"' src='"+getTreeIcon(siteItem)+"' border='0' width='19' height='16'></a></td>" );
else
_write( "<td class='chn'><img src='"+getTreeIcon(siteItem)+"' width='19' height='16'></td>" );
_write( "<td class='chn'><img src='"+scriptURL+"space.gif' width='3' height='16'></td>" );
}
var icon = siteItem.colapsedIcon;
if ( (browser == "OTHER") &&
(siteItem.children.length > 0) )
icon = siteItem.expandedIcon;
if ( icon != null )
{
outputItemAnchor( siteItem, "<img name='icon"+siteItem.id+"' src='"+scriptURL+icon+"' border='0' width='"+siteItem.iconWidth+"' height='"+siteItem.iconHeight+"'>" );
outputItemAnchor( siteItem, "<img src='"+scriptURL+"space.gif' border='0' width='3' height='16'>" );
}
if ( siteItem.text != null )
{
var s = siteItem.text;
if ( (siteItem.font != null) and and (siteItem.size != null) and and (siteItem.color != null) and and (browser == "IE") )
{
var s1 = "<font";
if ( browser == "IE" )
s1 += " id='style"+siteItem.id+"'";
if ( siteItem.font != null )
s1 += " face='"+siteItem.font+"'";
if ( siteItem.size != null )
s1 += " size='"+siteItem.size+"'";
if ( siteItem.color != null )
s1 += " color='"+siteItem.color+"'";
s1 += "class='chn'>";
s = s1+s+"</font>";
}
if ( siteItem.bold )
s = "<b class='chn'>"+s+"</b>";
if ( siteItem.italic )
s = "<i class='chn'>"+s+"</i>";
outputItemAnchor( siteItem, s );
}
_write( "<td width=100% class='chn'></td>" );
_write( "</tr>" );
if ( browser == "IE" )
{
_write( "</table>" );
siteItem.obj =do
cument.all["item"+siteItem.id];
siteItem.treeIcon =do
cument.all["treeIcon"+siteItem.id];
siteItem.icon =do
cument.all["icon"+siteItem.id];
if ( siteItem.text != null )
siteItem.style =do
cument.all["style"+siteItem.id].style;
}
else
if ( browser == "NS" )
{
_write( "</table>" );
_writeln( "</layer>" );
siteItem.obj =do
cument.sitemap.document.layers["item"+siteItem.id];
siteItem.treeIcon = siteItem.obj.document.images["treeIcon"+siteItem.id];
siteItem.icon = siteItem.obj.document.images["icon"+siteItem.id];
}
else
_writeln( "</table>" );
if ( (siteItem.last) and and (style != "TREE") )
left += "<td><img src='"+scriptURL+"blank.gif' width='19' height='16'></td>";
else
left += "<td><img src='"+scriptURL+"treeline.gif' width='19' height='16'></td>";
for ( var i=0;
i<siteItem.children.length;
i++ )
renderItem( siteItem.children, left );
}
function restoreIcons()
{
for ( var i=0;
i<items.length;
i++ )
updateIcons( items );
}
function selectItem( siteItem )
{
if ( selectedItem != null )
{
selectedItem.selected = false;
if ( selectedItem.style != null )
{
selectedItem.style.color = "";
selectedItem.style.backgroundColor = "";
}
updateIcons( selectedItem );
}
selectedItem = siteItem;
if ( siteItem != null )
{
siteItem.selected = true;
if ( siteItem.style != null )
{
siteItem.style.color = selectedColor;
siteItem.style.backgroundColor = selectedBackground;
}
updateIcons( siteItem );
}
}
function treeIconClicked( siteItem )
{
if ( (browser == "OTHER") and and (siteItem.children.length == 0) )
return;
if ( siteItem.opened )
colapse( siteItem );
else
expandColapse( siteItem );
siteItem.opened = !siteItem.opened;
updateIcons( siteItem );
adjustY();
}
function updateIcons( siteItem )
{
if ( (style != "LIST") &&
(siteItem.children.length != 0) )
siteItem.treeIcon.src = getTreeIcon(siteItem);
if ( siteItem.icon == null )
return;
if ( (siteItem.selected) &&
(siteItem.selectedIcon != null) )
siteItem.icon.src = scriptURL+siteItem.selectedIcon;
else
if ( (siteItem.mouseOver) &&
(siteItem.mouseOverIcon != null) )
siteItem.icon.src = scriptURL+siteItem.mouseOverIcon;
else
if ( siteItem.opened )
siteItem.icon.src = scriptURL+siteItem.expandedIcon;
else
siteItem.icon.src = scriptURL+siteItem.colapsedIcon;
}
function _write( s )
{
if ( browser == "NS" )
do
cument.sitemap.document.write( s );
else
do
cument.write( s );
}
function _writeln( s )
{
if ( browser == "NS" )
do
cument.sitemap.document.writeln( s );
else
do
cument.writeln( s );
}
function Item( colapsedIcon, expandedIcon, mouseOverIcon, selectedIcon, iconWidth, iconHeight, text, font, bold, italic, size, color, message, url, target, last )
{
this.id = items.length;
this.colapsedIcon = colapsedIcon;
this.expandedIcon = expandedIcon;
this.mouseOverIcon = mouseOverIcon;
this.selectedIcon = selectedIcon;
this.iconWidth = iconWidth;
this.iconHeight = iconHeight;
this.text = text;
this.font = font;
this.bold = bold;
this.italic = italic;
this.size = size;
this.color = color;
this.message = message;
this.url = url;
this.target = target;
this.opened = false;
this.selected = false;
this.mouseOver = false;
this.children = new Array();
this.last = last;
this.obj = null;
this.treeIcon = null;
this.icon = null;
this.style = null;
this.parent = null;
items[this.id] = this;
}
function addItem( siteItem, parent )
{
if ( parent == null )
topItems[topItems.length] = siteItem;
else
parent.children[parent.children.length] = siteItem;
siteItem.parent = parent;
}
function renderSitemap( _style, _expandTopItems, _mouseOverColor, _selectedColor, _selectedBackground, _scriptURL )
{
if (do
cument.all )
browser = "IE";
else
if (do
cument.layers )
browser = "NS";
if ( browser == "OTHER" )
_style = "LIST";
style = _style;
scriptURL = _scriptURL;
expandTopItems = _expandTopItems;
mouseOverColor = _mouseOverColor;
selectedColor = _selectedColor;
selectedBackground = _selectedBackground;
if ( browser == "NS" )
{
do
cument.writeln( "<ilayer id='sitemap' class='chn'></ilayer>" );
window.onLoad = display;
}
else
display();
}
调用部分:
addItem( new Item("licence.gif",null,null,null,16,16,"微网科技发展有限公司","",false,false,2,"#000000","","http://WWW.EQING.NET","_blank",false) );
level0 = new Item("windows.gif",null,null,null,16,16,"站 点 首 页","",false,false,2,"#000000","","default.asp","_blank",false);
addItem(level0);
level0 = new Item("folder-closed.gif","folder-open.gif",null,null,16,16,"MOAS Web站点维护","",false,false,2,"#000000","",null,null,false);
addItem(level0);
level1 = new Item("doc3.gif",null,null,null,16,16,"站点主题输入","",false,false,2,"#000000","","moasWEB/webmanager/Imageinfo/InsertTheme.asp","tool_main",false);
addItem(level1,level0);
level1 = new Item("info.gif",null,null,null,16,16,"站点主导航维护","",false,false,2,"#000000","","moasWEB/webmanager/left/first.asp","tool_main",false);
addItem(level1,level0);
level1 = new Item("book-purple-closed.gif",null,null,null,16,16,"企业信息注册","",false,false,2,"#000000","","register/RegisterCompany.asp","tool_main",false);
addItem(level1,level0);
level1 = new Item("folder-tools.gif",null,null,null,16,16,"站点主题选择","",false,false,2,"#000000","","moasWEB/webmanager/Imageinfo/ThemeChoose.asp","tool_main",false);
addItem(level1,level0);
level1 = new Item("folder-tools.gif",null,null,null,16,16,"站点友情链接维护","",false,false,2,"#000000","","moasWEB/webmanager/linkmanage.asp","tool_main",false);
addItem(level1,level0);
level1 = new Item("folder-tools.gif",null,null,null,16,16,"企业信息维护","",false,false,2,"#000000","","moasWEB/webmanager/CompanyInfo/UpdateCompany.asp","tool_main",false);
addItem(level1,level0);
level1 = new Item("folder-tools.gif",null,null,null,16,16,"站点样式表维护","",false,false,2,"#000000","","#","tool_main",false);
addItem(level1,level0);
level1 = new Item("folder-tools.gif",null,null,null,16,16,"招 聘 管 理","",false,false,2.5,"#000000","","moasWEB/webmanager/yingcaimanager.asp","tool_main",false);
addItem(level1,level0);
level1 = new Item("folder-tools.gif",null,null,null,16,16,"产 品 管
理","",false,false,2,"#000000","","moasWEB/webmanager/productmanager.asp","tool_main",false);
addItem(level1,level0);
level1 = new Item("folder-tools.gif",null,null,null,16,16,"新 闻 管
理","",false,false,2,"#000000","","moasWEB/webmanager/newsmanager.asp","tool_main",false);
addItem(level1,level0);
level1 = new Item("folder-tools.gif",null,null,null,16,16,"大事记管理","",false,false,2,"#000000","","moasWEB/webmanager/dashijimanager.asp","tool_main",false);
addItem(level1,level0);
level1 = new Item("java1.gif",null,null,null,16,16,"客户留言管
理","",false,false,2,"#000000","","moasWEB/webmanager/liuyanmanager/liuyanmanage.asp","tool_main",false);
addItem(level1,level0);
level1 = new Item("drive-shared.gif",null,null,null,16,16,"诚征代理管
理","",false,false,2,"#000000","","moasWEB/webmanager/dailimanager/dailimanage.asp","tool_main",false);
addItem(level1,level0);
level1 = new Item("icon-mac.gif",null,null,null,16,16,"滚动通知管
理","",false,false,2,"#000000","","moasWEB/webmanager/topnewsmanager.asp","tool_main",false);
addItem(level1,level0);
level1 = new Item("users.gif",null,null,null,16,16,"用 户 管 理","",false,false,2,"#000000","","moasWEB/webmanager/user/manager.htm","tool_main",true);
addItem(level1,level0);
level0 = new Item("folder-closed.gif","folder-open.gif",null,null,16,16,"分类页面内容维护","",false,false,2,"#000000","",null,null,true);
addItem(level0);
level1 = new Item("new.gif",null,null,null,16,16,"新 闻 发 布","",false,false,2,"#000000","","moasWEB/webmanager/PageManage/Page.asp?ItemOrder=1","tool_main",false);
addItem(level1,level0);
level1 = new Item("icon-mac.gif",null,null,null,16,16,"公 司 简 介","",false,false,2,"#000000","","moasWEB/webmanager/PageManage/Page.asp?ItemOrder=2","tool_main",false);
addItem(level1,level0);
level1 = new Item("icon-kde.gif",null,null,null,16,16,"产 品 在 线","",false,false,2,"#000000","","moasWEB/webmanager/PageManage/Page.asp?ItemOrder=3","tool_main",false);
addItem(level1,level0);
level1 = new Item("java1.gif",null,null,null,16,16,"客 户 留 言","",false,false,2,"#000000","","moasWEB/webmanager/PageManage/Page.asp?ItemOrder=4","tool_main",false);
addItem(level1,level0);
level1 = new Item("drive-shared.gif",null,null,null,16,16,"诚 征 代
理","",false,false,2,"#000000","","moasWEB/webmanager/PageManage/Page.
asp?ItemOrder=5","tool_main",false);
addItem(level1,level0);
level1 = new Item("icon-mac.gif",null,null,null,16,16,"诚 聘 英
才","",false,false,2,"#000000","","moasWEB/webmanager/PageManage/Page.
asp?ItemOrder=6","tool_main",false);
addItem(level1,level0);
level1 = new Item("icon-kde.gif",null,null,null,16,16,"企业大事
记","",false,false,2,"#000000","","moasWEB/webmanager/PageManage/Page
.asp?ItemOrder=7","tool_main",true);
addItem(level1,level0);
renderSitemap( "TREE", true, "#000000", "#ffffff", "#23007C", "surfmapjs/" );