function InitMenu() {
var bar = menuBar.children
for (var i = 0; i < bar.length; i++) {
var menu = eval(bar[i].menu) menu.style.visibility = "hidden"
bar[i].onmouseover = new Function("ShowMenu(" + bar[i].id + ")") var Items = menu.children
for (var j = 0; j < Items.length; j++) {
var menuItem = eval(Items[j].id) if (menuItem.menu != null) {
menuItem.innerHTML += "<Span Id=" + menuItem.id + "_Arrow class='Arrow'>4</Span>" //var tmp = eval(menuItem.id+"_Arrow")
// tmp.style.pixelLeft = menu.getBoundingClientRect().Right //- tmp.offsetWidth - 15
FindSubMenu(menuItem.menu)
}
if (menuItem.cmd != null) {
menuItem.onclick = new Function("Do(" + menuItem.id + ")")
}
menuItem.onmouseover = new Function("highlight(" + Items[j].id + ")")
}
}
}
答案 0 :(得分:-1)
eval
只能在数据为json对象时使用。我假设你在一个名为&#34; menuBar&#34;
var menuBar=document.getElementById("menuBar");
function InitMenu() {
var bar = menuBar.childNodes;
for (var i = 0; i < bar.length; i++) {
var menu = bar[i];
menu.style.visibility = "hidden";
bar[i].onmouseover = new Function("ShowMenu(" + bar[i].id + ")") var Items = menu.children
for (var j = 0; j < Items.length; j++) {
var menuItem = eval(Items[j].id) if (menuItem.menu != null) {
menuItem.innerHTML += "<Span Id=" + menuItem.id + "_Arrow class='Arrow'>4</Span>" //var tmp = eval(menuItem.id+"_Arrow")
// tmp.style.pixelLeft = menu.getBoundingClientRect().Right //- tmp.offsetWidth - 15
FindSubMenu(menuItem.menu)
}
if (menuItem.cmd != null) {
menuItem.onclick = new Function("Do(" + menuItem.id + ")")
}
menuItem.onmouseover = new Function("highlight(" + Items[j].id + ")")
}
}
}