posLeft = 2;
posTop = 1;
for (i=0;i<menu.bar.length;i++) {
strHTML = "<div id='" + menu.bar[i].name + "' nowrap style='left:" + posLeft + ";top:" + posTop + ";' class='MainMenu' " +
"onmouseover='return menu_onmouseover(this,\"" + menu.bar[i].cmd + "\")' onmouseout='return menu_onmouseout(this)' " +
"onclick='return menu_onclick(this,\"" + menu.bar[i].cmd + "\")' title='" + menu.bar[i].tip + "'>" + menu.bar[i].text;
if (menu.bar[i].key!="") {
strHTML += "(<u>" + menu.bar[i].key + "</u>)";
}
strHTML += "</div>";
document.write (strHTML);
posLeft += document.all.item(menu.bar[i].name).offsetWidth + 1;
}
strHTML = "</div>";
document.write (strHTML);
}
//输出一个已定义的子菜单,竖排的
function popSubMenu(menu) {
var strHTML, posLeft, posTop, i;
strHTML = "<div id='" + menu.name + "' style='left:20;top:30;width:244;height:300;' class='SubMenuBG'>"
document.write (strHTML);
posLeft = 1;
posTop = 1;
for (i=0;i<menu.bar.length;i++) {
if (menu.bar[i].name!="\-") { //如果名称不是“\-”,表示是一个普通菜单条
strHTML = "<div id='" + menu.bar[i].name + "' style='left:" + posLeft + ";top:" + posTop + ";' class='SubMenu' " +
"title='" + menu.bar[i].tip + "' " +
"onmouseover='return bar_onmouseover(this," + menu.bar[i].type + ",\"" + menu.bar[i].cmd + "\")' " +
"onmouseout='return bar_onmouseout(this," + menu.bar[i].type + ",\"" + menu.bar[i].cmd + "\")' " +
"onclick='return bar_onclick(this," + menu.bar[i].type + ",\"" + menu.bar[i].cmd + "\")'>" +
" <table border=0 cellspacing=0 cellpadding=0 width=240>" +
" <tr>" +
" <td nowrap align=center width=20 id='" + menu.bar[i].name + "_ico' class='ico'>";
if (menu.bar[i].ico!="") {
strHTML += "<img border=0 width=16 height=16 src='" + menu.bar[i].ico + "'>";
}else {
strHTML += " ";
}
strHTML += "</td>" +
" <td nowrap id='" + menu.bar[i].name + "_text' class='text'>" + menu.bar[i].text;
if (menu.bar[i].key!="") { strHTML = strHTML + "(<u>" + menu.bar[i].key + "</u>)"; }
strHTML += "</td>" +
"<td nowrap align=right id='" + menu.bar[i].name + "_skey' class='skey'>";
if (menu.bar[i].skey!="") {
strHTML += menu.bar[i].skey;
}else {
strHTML += " ";
}
strHTML += " </td>" +
" <td nowrap align=center width=20 id='" + menu.bar[i].name + "_sub' class='sub'>";
if (menu.bar[i].type==0) {
strHTML += "→";
}else {
strHTML += " ";
}
strHTML += "</td>" +
" </tr>" +
" </table>" +
"</div>";
document.write (strHTML);
posTop += document.all.item(menu.bar[i].name).offsetHeight;
}else { //如果名称是“\-”,表示是一条分隔线
strHTML = "<div style='left:" + posLeft + ";top:" + posTop + ";' class='SubMenu'>" +
" <table border=0 cellpadding=0 cellspacing=0 width=240>" +
" <tr>" +
" <td nowrap style='background-color: #dedbd6;' width=21></td>" +
" <td nowrap style='padding-left:5px;padding-top:1px;padding-bottom:1px;'>" +
" <table border=0 cellpadding=0 cellspacing=0 width=100%>" +
" <tr><td height=1 bgcolor='#636563'></td></tr>" +
" </table>" +
" </td>" +
" </tr>" +
" </table>" +
"</div>";
document.write (strHTML);
posTop += 3;
}
}
文章来源于领测软件测试网 https://www.ltesting.net/