//生成菜单项
out += "<td bgcolor=buttonface align=center valign=middle>\n<table border=0 cellpadding=0 cellspacing=0>\n";
for (var i=0; i<this.item.length; i++) {
var imenu = this.item[i];
if (imenu.text!="-") { //正常的菜单项
out+="<tr>\n<td valign=middle>\n"+
"<table border=0 cellpadding=0 cellspacing=0 width="+(MENUWIDTH-4)+" class=popupitem onclick=\""+imenu.action+"\" "+
"onmouseover=\"this.className='popupitemhigh'\" onmouseout=\"this.className='popupitem'\">\n"+
"<tr valign=middle>\n<td width=18 align=center>\n";
if (typeof(imenu.image)!="undefined" && imenu.image != "") { //菜单图片
out+="<img src=\""+imenu.image+"\" height=16 width=16>";
}
out+="</td>\n<td valign=middle>"+imenu.text+"</td>\n"; //菜单文字
out+="</tr>\n</table>\n</td></tr>\n";
} else { //分隔线
out+="<tr>\n<td valign=middle align=center height=8>\n"+
"<table border=0 cellpadding=0 cellspacing=0 width="+(MENUWIDTH-4)+">"+
"<tr><td height=1 bgcolor=buttonshadow></td></tr>"+
"<tr><td height=1 bgcolor=buttonhighlight></td></tr>"+
"</table>\n</td>\n</tr>\n";
}
}
out+="</table>\n</td>\n</tr>\n</table>\n</div>\n"; if (popupmenuList.length==1) { //生成脚本(只需写一次)
var js="<style type=\"text/css\">\n"+
".popupitem {\n"+
" font-size: "+MENUITEM_FONTSIZE+"; "+ //菜单项字体大小
" line-height: "+MENUITEM_HEIGHT+"px; "+ //菜单项高度
" background-color:buttonface;\n"+
" color:buttontext;\n"+
"}\n"+
".popupitemhigh {\n"+
" font-size: "+MENUITEM_FONTSIZE+"; "+ //菜单项字体大小
" line-height: "+MENUITEM_HEIGHT+"px; "+ //菜单项高度
" background-color:highlight;\n"+
" color:highlighttext;\n"+
"}\n"+
"</style>\n";
document.write(js);
document.body.onclick=new Function("hidepopupmenu(); return false;");
document.body.onscroll=new Function("hidepopupmenu(); return false;");
document.body.onselectstart=new Function("hidepopupmenu(); return false;");
window.onresizestart=new Function("hidepopupmenu(); return false;");
} document.write(out);
this.object=document.all(this.id);
this.ctl.oncontextmenu=new Function("return showpopupmenu('"+this.id+"');");
}
}function hidepopupmenu() {
for (var i=0; i<popupmenuList.length; i++) {
popupmenuList[i].hide();
}
}function showpopupmenu(menuid) {
hidepopupmenu(); var popupmenu=document.all(menuid); if (event.srcElement.tagName=="IMG"&&event.srcElement.id!=(this.id+"logo")||
event.srcElement.tagName=="A"||
event.srcElement.tagName=="TEXTAREA"||
event.srcElement.tagName=="INPUT"||
document.selection.type!="None") {
return true;
} else {
popupmenu.style.left=event.clientX+document.body.scrollLeft;
popupmenu.style.top=event.clientY+document.body.scrollTop; popupmenu.style.visibility='visible';
} return false;
}
</script>
<!-- menu.js 结束 -->
</head>
<body>
<div class="ibox" id="pop1" valign=middle>第一个菜单</div>
<script>
var popmenu = new popupmenu();
popmenu.logo.src="menu.gif";
popmenu.width=150;
popmenu.ctl=pop1;
popmenu.add("后退","window.history.back()");
popmenu.add("前进","window.history.forward()");
popmenu.add("-");
popmenu.add("返回讨论版","alert('空');");
popmenu.add("作者相关文章","alert('空');");
popmenu.add("作者全部文章","alert('空');");
popmenu.add("-");
popmenu.add("全选","document.execCommand('SelectAll')");
popmenu.add("另存为…","document.execCommand('SaveAs','true')");
popmenu.add("查看源文件","location.replace('view-source:'+location.href)");
popmenu.add("打印","window.print()");
popmenu.add("刷新","window.location.reload()");
popmenu.print();
</script>
.....
这有N个table,我不想每个td都加个class="?",所以我用了上面的CSS td{}来控制,但这样会使右键的菜单变样,请帮忙解决.谢谢
.....
</body>
</html>
我不想每个td都加个class="?",所以我用了上面的CSS td{}来控制,但这样会使右键的菜单变样,请帮忙解决.谢谢
out += "<td bgcolor=buttonface align=center valign=middle>\n<table border=0 cellpadding=0 cellspacing=0>\n";
for (var i=0; i<this.item.length; i++) {
var imenu = this.item[i];
if (imenu.text!="-") { //正常的菜单项
out+="<tr>\n<td valign=middle>\n"+
"<table border=0 cellpadding=0 cellspacing=0 width="+(MENUWIDTH-4)+" class=popupitem onclick=\""+imenu.action+"\" "+
"onmouseover=\"this.className='popupitemhigh'\" onmouseout=\"this.className='popupitem'\">\n"+
"<tr valign=middle>\n<td width=18 align=center>\n";
if (typeof(imenu.image)!="undefined" && imenu.image != "") { //菜单图片
out+="<img src=\""+imenu.image+"\" height=16 width=16>";
}
out+="</td>\n<td valign=middle>"+imenu.text+"</td>\n"; //菜单文字
out+="</tr>\n</table>\n</td></tr>\n";
} else { //分隔线
out+="<tr>\n<td valign=middle align=center height=8>\n"+
"<table border=0 cellpadding=0 cellspacing=0 width="+(MENUWIDTH-4)+">"+
"<tr><td height=1 bgcolor=buttonshadow></td></tr>"+
"<tr><td height=1 bgcolor=buttonhighlight></td></tr>"+
"</table>\n</td>\n</tr>\n";
}
}
out+="</table>\n</td>\n</tr>\n</table>\n</div>\n"; if (popupmenuList.length==1) { //生成脚本(只需写一次)
var js="<style type=\"text/css\">\n"+
".popupitem {\n"+
" font-size: "+MENUITEM_FONTSIZE+"; "+ //菜单项字体大小
" line-height: "+MENUITEM_HEIGHT+"px; "+ //菜单项高度
" background-color:buttonface;\n"+
" color:buttontext;\n"+
"}\n"+
".popupitemhigh {\n"+
" font-size: "+MENUITEM_FONTSIZE+"; "+ //菜单项字体大小
" line-height: "+MENUITEM_HEIGHT+"px; "+ //菜单项高度
" background-color:highlight;\n"+
" color:highlighttext;\n"+
"}\n"+
"</style>\n";
document.write(js);
document.body.onclick=new Function("hidepopupmenu(); return false;");
document.body.onscroll=new Function("hidepopupmenu(); return false;");
document.body.onselectstart=new Function("hidepopupmenu(); return false;");
window.onresizestart=new Function("hidepopupmenu(); return false;");
} document.write(out);
this.object=document.all(this.id);
this.ctl.oncontextmenu=new Function("return showpopupmenu('"+this.id+"');");
}
}function hidepopupmenu() {
for (var i=0; i<popupmenuList.length; i++) {
popupmenuList[i].hide();
}
}function showpopupmenu(menuid) {
hidepopupmenu(); var popupmenu=document.all(menuid); if (event.srcElement.tagName=="IMG"&&event.srcElement.id!=(this.id+"logo")||
event.srcElement.tagName=="A"||
event.srcElement.tagName=="TEXTAREA"||
event.srcElement.tagName=="INPUT"||
document.selection.type!="None") {
return true;
} else {
popupmenu.style.left=event.clientX+document.body.scrollLeft;
popupmenu.style.top=event.clientY+document.body.scrollTop; popupmenu.style.visibility='visible';
} return false;
}
</script>
<!-- menu.js 结束 -->
</head>
<body>
<div class="ibox" id="pop1" valign=middle>第一个菜单</div>
<script>
var popmenu = new popupmenu();
popmenu.logo.src="menu.gif";
popmenu.width=150;
popmenu.ctl=pop1;
popmenu.add("后退","window.history.back()");
popmenu.add("前进","window.history.forward()");
popmenu.add("-");
popmenu.add("返回讨论版","alert('空');");
popmenu.add("作者相关文章","alert('空');");
popmenu.add("作者全部文章","alert('空');");
popmenu.add("-");
popmenu.add("全选","document.execCommand('SelectAll')");
popmenu.add("另存为…","document.execCommand('SaveAs','true')");
popmenu.add("查看源文件","location.replace('view-source:'+location.href)");
popmenu.add("打印","window.print()");
popmenu.add("刷新","window.location.reload()");
popmenu.print();
</script>
.....
这有N个table,我不想每个td都加个class="?",所以我用了上面的CSS td{}来控制,但这样会使右键的菜单变样,请帮忙解决.谢谢
.....
</body>
</html>
我不想每个td都加个class="?",所以我用了上面的CSS td{}来控制,但这样会使右键的菜单变样,请帮忙解决.谢谢
我不想每个td都加个class="?",所以我用了上面的CSS td{}来控制,但这样会使右键的菜单变样,请帮忙解决.谢谢
color:red;
} class=abcde的tag(如div,table或其它tag)所包含的td的样式
-----------------
....
<style>
.abcde td{
color:red;
}
</style>
....
再把js里的这一句改一下:
//生成菜单边框
var out="<div id="+this.id+" style=\""+----->>>>> //生成菜单边框
var out="<div id="+this.id+" class=abcde style=\""+
按你的做可以了.