怎样动态生成一个菜单

yanyl2001 2003-10-20 01:20:35
怎样动态生成一个菜单,但不是树哦
...全文
60 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
lyhold 2003-10-20
  • 打赏
  • 举报
回复
popupmenu.html
************************************
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML xmlns:MSHelp=http://msdn.microsoft.com/msHelp>
<HEAD>
<TITLE>oncontextmenu Event Sample</TITLE>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=iso-8859-1">
<META NAME="AUTHOR" CONTENT="InetSDK">
<META NAME="MS.LOCALE" CONTENT="EN-US">
<META NAME="ROBOTS" CONTENT="noindex">

<STYLE>
.menuItem {font-family:sans-serif;font-size:10pt;width:100;padding-left:20;
background-Color:menu;color:black}
.highlightItem {font-family:sans-serif;font-size:10pt;width:100;padding-left:20;
background-Color:highlight;color:white}
.clickableSpan {padding:4;width:500;background-Color:blue;color:white;border:5px gray solid}
</STYLE>

<SCRIPT>
//<!--

function displayMenu() {
whichDiv=event.srcElement;
menu1.style.leftPos+=10;
menu1.style.posLeft=event.clientX;
menu1.style.posTop=event.clientY;
menu1.style.display="";
menu1.setCapture();
}
function switchMenu() {
el=event.srcElement;
if (el.className=="menuItem") {
el.className="highlightItem";
} else if (el.className=="highlightItem") {
el.className="menuItem";
}
}
function clickMenu() {
menu1.releaseCapture();
menu1.style.display="none";
el=event.srcElement;
if (el.id=="mnuRed") {
whichDiv.style.backgroundColor="red";
} else if (el.id=="mnuGreen") {
whichDiv.style.backgroundColor="green";
} else if (el.id=="mnuBlue") {
whichDiv.style.backgroundColor="blue";
} else if (el.id=="mnuYellow") {
whichDiv.style.backgroundColor="yellow";
}
}

//-->
</SCRIPT>


<!-- SAMPLE_STYLE_START -->
<LINK REL="stylesheet" HREF="/workshop/basicSDKIE4.css" TYPE="text/css">
<!-- SAMPLE_STYLE_END -->
<LINK REL="stylesheet" TYPE="text/css" HREF="ms-help://Hx/HxRuntime/HxLink.css"><STYLE TYPE="text/css">
PRE.clsCode { font-size:110%; }
PRE.clsSyntax { font-size:100%; }
TD DIV.clsBeta { display:none;}
MSHelp\:link {
color:#0000ff;
text-decoration:underline;
cursor:hand;
hoverColor:#3366ff;
filterString: ;}
</STYLE>
</HEAD>
<!-- TOOLBAR_START -->
<!-- TOOLBAR_EXEMPT -->
<!--TOOLBAR_END-->

<BODY TOPMARGIN=0 LEFTMARGIN=0 BGPROPERTIES="FIXED" BGCOLOR="#FFFFFF"
LINK="#000000" VLINK="#808080" ALINK="#000000">
<BLOCKQUOTE CLASS="body">

<!-- CONTENTS_START -->
<H1>oncontextmenu Event Sample</H1>
<P>This sample shows how to use the <B>oncontextmenu</B> event handler, available in Microsoft® Internet Explorer 5 and later, to display both standard and custom context menus and prevent context menus from displaying. Experiment with each of the following boxes to see how you can apply different methods either to display or to inhibit context menus. Each box provides instructions for you to follow.
</P>

<SPAN class="clickableSpan">
1. The default context menu always displays when you right-click in this box.
<b><br>Code: </b>
//no code necessary
</SPAN><br><br>

<SPAN class="clickableSpan" oncontextmenu="return event.ctrlKey">
2. The default context menu displays only if you right-click in this box while holding down the Ctrl key. This is useful for developing and debugging purposes.
<b><br>Code: </b>
oncontextmenu="return event.ctrlKey"
</SPAN><br><br>

<SPAN class="clickableSpan" oncontextmenu="return false">
3. A context menu never displays when you right-click in this box.
<b><br>Code: </b>
oncontextmenu="return false"
</SPAN><br><br>

<SPAN class="clickableSpan" oncontextmenu="displayMenu();return false">
4. A custom context menu displays when you right-click in this box.
<b><br>Code: </b>
oncontextmenu="showMenu();return false;"
</SPAN><br><br>

<SPAN class="clickableSpan" oncontextmenu="if (!event.ctrlKey){displayMenu();return false;}">
5. A custom menu displays when you right-click in this box. If you right-click while holding down the Ctrl key, the default context menu displays.
<b><br>Code: </b>
oncontextmenu="if (!event.ctrlKey){displayMenu();return false;}"
</SPAN><br>

<div id=menu1 onclick="clickMenu()" onmouseover="switchMenu()" onmouseout="switchMenu()" style="position:absolute;display:none;width:100;background-Color:menu; border: outset 3px gray">
<div class="menuItem" id=mnuRed>Red</div>
<div class="menuItem" id=mnuGreen>Green</div>
<div class="menuItem" id=mnuBlue>Blue</div>
<div class="menuItem" id=mnuYellow>Yellow</div>
</div>


<!-- CONTENTS_END -->
<!-- START_PAGE_FOOTER -->
<BR><BR><BR>
<MSHelp:link xmlns:MSHelp="http://msdn.microsoft.com/mshelp" keywords="msdn_copyright" TABINDEX="0">© 2003 Microsoft Corporation. All rights reserved.</MSHelp:link>.
<!-- END_PAGE_FOOTER -->
</BLOCKQUOTE>
</BODY>
</HTML>


fangyan1999 2003-10-20
  • 打赏
  • 举报
回复
function mexec2(x){
var cmd;
if(mmenus[x].target=="blank"){
cmd = "window.open('"+mmenus[x].command+"')";
}else{
cmd = mmenus[x].target+".location=\""+mmenus[x].command+"\"";
}
eval(cmd);
}
function mexec(x,i){
var cmd;
if(mmenus[x].items[i].target=="blank"){
cmd = "window.open('"+mmenus[x].items[i].command+"')";
}else{
cmd = mmenus[x].items[i].target+".location=\""+mmenus[x].items[i].command+"\"";
}
eval(cmd);
}
function mbody_click(){

if (misShow){
srcel = getReal(window.event.srcElement, "className", "coolButton");
for(var x=0;x<=mmenus.length;x++){
if(srcel.id=="mMenu"+x)
return;
}
for(x=1;x<=mnumberofsub;x++){
if(srcel.id=="mp"+x)
return;
}
mallhide();
}
}
document.onclick=mbody_click;
fangyan1999 2003-10-20
  • 打赏
  • 举报
回复
function mwritetodocument(){
var mwb=1;
var stringx='<div id="mposflag" style="position:absolute;"></div><table id=mmenutable border=0 cellpadding=3 cellspacing=2 width='+mmenuwidth+' height='+mmenuheight+' bgcolor='+mmenucolor+
' onselectstart="event.returnValue=false"'+
' style="filter:Alpha(Opacity=80);cursor:'+mcursor+';'+mfonts+
' border-left: '+mwb+'px solid '+mmenuoutbordercolor+';'+
' border-right: '+mwb+'px solid '+mmenuinbordercolor+'; '+
'border-top: '+mwb+'px solid '+mmenuoutbordercolor+'; '+
'border-bottom: '+mwb+'px solid '+mmenuinbordercolor+'; padding:0px"><tr>'
for(var x=0;x<mmenus.length;x++){
var thismenu=mmenus[x];
var imgsize="";
if(thismenu.sizex!="0"||thismenu.sizey!="0")imgsize=" width="+thismenu.sizex+" height="+thismenu.sizey;
var ifspace="";
if(thismenu.caption!="")ifspace=" ";
stringx += "<td nowrap class=coolButton id=mMenu"+x+" style='border: "+mitemedge+"px solid "+mmenucolor+
"' width="+mmenuunitwidth+"px onmouseover=mmenu_over(mmenudiv"+x+
","+x+") onmouseout=mmenu_out("+x+
") onmousedown=mmenu_down(mmenudiv"+x+","+x+")";
if(thismenu.command!=""){
stringx += " onmouseup=mmenu_up();mexec2("+x+");";
}else{
stringx += " onmouseup=mmenu_up()";
}
if(thismenu.pos=="0"){
stringx += " align=center><img align=absmiddle src='"+thismenu.img+"'"+imgsize+">"+ifspace+thismenu.caption+"</td>";
}else if(thismenu.pos=="1"){
stringx += " align=center>"+thismenu.caption+ifspace+"<img align=absmiddle src='"+thismenu.img+"'"+imgsize+"></td>";
}else if(thismenu.pos=="2"){
stringx += " align=center background='"+thismenu.img+"'> "+thismenu.caption+" </td>";
}else{
stringx += " align=center> "+thismenu.caption+" </td>";
}
stringx += "";
}
stringx+="<td width=*> </td></tr></table>";


for(var x=0;x<mmenus.length;x++){
thismenu=mmenus[x];
if(x<0){
stringx+='<div id=mmenudiv'+x+' ></tr>\n';
}
}
stringx+='</table>\n</div>'
}
document.write("<div align='center' id='JsMenuCSS'>"+stringx+"</div>");
}
helloqiqi 2003-10-20
  • 打赏
  • 举报
回复
用javascript可以做的
cuike519 2003-10-20
  • 打赏
  • 举报
回复
用ASPMenu可以(动态加载XML)!
也可以用SolpartWebControls(这个是免费的并且可以直接读取DataTable不用XML(可选的))!
goody9807 2003-10-20
  • 打赏
  • 举报
回复
up
seesea125 2003-10-20
  • 打赏
  • 举报
回复
做javascript,asp怎么做你也怎么做拉
liuyd 2003-10-20
  • 打赏
  • 举报
回复
up

关注,,,

62,041

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧