帮帮忙吧!
原menu。js文件:
if (document.all) {n=0;ie=1;fShow="visible";fHide="hidden";}
if (document.layers) {n=1;ie=0;fShow="show"; fHide="hide";}
window.onerror=new Function("return true")
////////////////////////////////////////////////////////////////////////////
// Function Menu() //
////////////////////////////////////////////////////////////////////////////
rightX = 0;
function Menu()
{
this.bgColor = "#008080";
if (ie) this.menuFont = "bold xx-small Verdana";
if (n) this.menuFont = "bold x-small Verdana";
// this.fontColor = "white";
this.addItem = addItem;
this.addSubItem = addSubItem;
this.showMenu = showMenu;
this.mainPaneBorder = 0;
this.subMenuPaneBorder = 0;
this.subMenuPaneWidth = 150;
lastMenu = null;
rightY = 0;
leftY = 0;
leftX = 0;
HTMLstr = "";
HTMLstr += "\n";
HTMLstr += "\n";
if (ie) HTMLstr += "
\n";
// if (n) HTMLstr += "
\n";
HTMLstr += "\n";
HTMLstr += "";
if (n) HTMLstr += " "; HTMLstr += "\n"; HTMLstr += "\n"; HTMLstr += "\n"; if (n) HTMLstr += " | ";
HTMLstr += "
\n";
HTMLstr += "
\n";
HTMLstr += "\n";
HTMLstr += "\n";
HTMLstr += "\n";
HTMLstr += "\n";
HTMLstr += "\n";
if (ie) HTMLstr+= "\n";
// if (n) HTMLstr+= "\n";
HTMLstr += "\n";
}
function addItem(idItem, text, hint, location, altLocation)
{
var Lookup = "";
if (HTMLstr.indexOf(Lookup) != -1)
{
alert(idParent + " already exist");
return;
}
var MENUitem = "";
MENUitem += "\n\n";
if (n)
{
MENUitem += "
";
MENUitem += "";
MENUitem += "";
}
if (ie)
{
MENUitem += "
\n"; MENUitem += "\n"; MENUitem += " | \n";
}
MENUitem += "\n\n";
MENUitem += "\n";
HTMLstr = HTMLstr.replace("\n", MENUitem);
}
function addSubItem(idParent, text, hint, location)
{
var MENUitem = "";
Lookup = "";
if (HTMLstr.indexOf(Lookup) == -1)
{
alert(idParent + " not found");
return;
}
Lookup = "";
if (HTMLstr.indexOf(Lookup) == -1)
{
if (n)
{
MENUitem += "\n";
MENUitem += "\n";
MENUitem += "\n";
}
if (ie)
{
MENUitem += "\n";
MENUitem += "\n";
MENUitem += "\n";
}
MENUitem += "\n";
HTMLstr = HTMLstr.replace("\n", MENUitem);
}
Lookup = "\n";
if (n) MENUitem = "
|
\n";
if (ie) MENUitem = "
|
\n";
MENUitem += Lookup;
HTMLstr = HTMLstr.replace(Lookup, MENUitem);
}
function showMenu()
{
document.writeln(HTMLstr);
}
////////////////////////////////////////////////////////////////////////////
// Private declaration
function displaySubMenu(idMainMenu)
{
var menu;
var submenu;
if (n)
{
submenu = document.layers[idMainMenu+"submenu"];
if (lastMenu != null && lastMenu != submenu) hideAll();
submenu.left = document.layers[idMainMenu].pageX;
submenu.top = document.layers[idMainMenu].pageY + 25;
submenu.visibility = fShow;
leftX = document.layers[idMainMenu+"submenu"].left;
rightX = leftX + document.layers[idMainMenu+"submenu"].clip.width;
leftY = document.layers[idMainMenu+"submenu"].top+
document.layers[idMainMenu+"submenu"].clip.height;
rightY = leftY;
} else if (ie) {
menu = eval(idMainMenu);
submenu = eval(idMainMenu+"submenu.style");
submenu.left = calculateSumOffset(menu, 'offsetLeft');
// submenu.top = calculateSumOffset(menu, 'offsetTop') + 30;
submenu.top = menu.style.top+23;
submenu.visibility = fShow;
if (lastMenu != null && lastMenu != submenu) hideAll();
leftX = document.all[idMainMenu+"submenu"].style.posLeft;
rightX = leftX + document.all[idMainMenu+"submenu"].offsetWidth;
leftY = document.all[idMainMenu+"submenu"].style.posTop+
document.all[idMainMenu+"submenu"].offsetHeight;
rightY = leftY;
}
lastMenu = submenu;
}
function hideAll()
{
if (lastMenu != null) {lastMenu.visibility = fHide;lastMenu.left = 0;}
}
function calculateSumOffset(idItem, offsetName)
{
var totalOffset = 0;
var item = eval('idItem');
do
{
totalOffset += eval('item.'+offsetName);
item = eval('item.offsetParent');
} while (item != null);
return totalOffset;
}
function updateIt(e)
{
if (ie)
{
var x = window.event.clientX;
var y = window.event.clientY;
if (x > rightX || x < leftX) hideAll();
else if (y > rightY) hideAll();
}
if (n)
{
var x = e.pageX;
var y = e.pageY;
if (x > rightX || x < leftX) hideAll();
else if (y > rightY) hideAll();
}
}
if (document.all)
{
document.body.onclick=hideAll;
document.body.onscroll=hideAll;
document.body.onmousemove=updateIt;
}
if (document.layers)
{
document.onmousedown=hideAll;
window.captureEvents(Event.MOUSEMOVE);
window.onmousemove=updateIt;
}
原menucontext。js文件:
function showToolbar()
{
// AddItem(id, text, hint, location, alternativeLocation);
// AddSubItem(idParent, text, hint, location);
menu = new Menu();
menu.addItem("home", "首页", "首页", null, null);
menu.addItem("computer", "计算机技术", "计算机技术", null, null);
menu.addItem("txl", "同学录", "同学录", null, null);
menu.addItem("lm", "栏目简介", "栏目简介", null, null);
menu.addItem("tz", "推荐网站", "推荐网站", null, null);
menu.addSubItem("home", "本站简介", "本站简介", "http://go.163.com/hz9841/htmls/txl.html");
menu.addSubItem("home", "站长自我介绍", "站长自我介绍", "http://go2.163.com/hz9841/htmls/txl1.html");
menu.addSubItem("computer", "Windows", "windows", "http://go.163.com/hz9841/htmls/txl.html");
menu.addSubItem("computer", "Windows_NT", "windowsNT", "http://go.163.com/hz9841/htmls/txl.html");
menu.addSubItem("computer", "Unix", "unix", "http://go.163.com/hz9841/htmls/txl.html");
menu.addSubItem("computer", "网络技术", "网络技术", "http://go.163.com/hz9841/htmls/txl.html");
menu.addSubItem("txl","同学录1", "同学录1", "http://go.163.com/hz9841/htmls/txl.html");
menu.addSubItem("txl","同学录2", "同学录2", "http://go.163.com/hz9841/htmls/txl1.html");
menu.addSubItem("lm","同学录", "同学录", "");
menu.addSubItem("lm","过客留言", "过客留言", "");
menu.addSubItem("lm","计算机技术", "计算机技术", "");
menu.addSubItem("lm","推荐网站", "推荐网站", "");
menu.addSubItem("tz","黑狐狸网络", "黑狐狸网络", "http://www.sthacker.com");
menu.addSubItem("tz","5D多媒体", "5D多媒体", "http://www.5dmedia.com");
menu.addSubItem("tz","搜狐", "搜狐", "http://www.sohu.com");
menu.showMenu();
}