阿赖的菜单控件
经典Windows样式菜单应用示例
点击上面的菜单栏显示相应的菜单,点击鼠标右键可显示右键菜单!
程序代码:
copywrite by 赖国欣 2003/6 All right reserved
Email: a@lai.com.cn website:
http://www.9499.net/
/***********************************
经典Windows样式菜单应用示例
赖国欣设计于2003年6月,保留所有权利!
************************************/
/*建立5个菜单实例对象*/
var m1=new alai_menu()
var m2=new alai_menu()
var m3=new alai_menu()
var m4=new alai_menu()
var m5=new alai_menu()
var m6=new alai_menu()
/*菜单栏*/
var mc=new menu_bar(10,20);
mc.add("菜单功能演示",m1)
mc.add("网址收藏",m2)
mc.add("其它",m3)
/*添加菜单项*/
m1.add("显示子菜单","sub",m3)
m1.add("执行JS命令","js","alert('谢谢使用');")
m1.add("隐藏菜单","hide")
m1.add("去google一下","url","http://www.google.com","_blank")
m1.seperate()//加分隔线
var item=m1.add("enable=false","js","alert('谢谢使用');")
item.enable=false
var itemDel=m1.add("请把我移除")
itemDel.execute=function(){itemDel.remove();}
m1.seperate()//加分隔线
m1.add("动态增加菜单项...").execute=function(){var txt=prompt("输入文字:");m1.add(txt);}
m2.addLink("http://msdn.microsoft.com/library/default.asp","MSDN Library")
m2.addLink("http://www.csdn.net","程序员大本营")
m2.addLink("http://www.google.net")
m2.addLink("http://www.devarticles.com","DevArticles")
m3.add("无限级子菜单演示","sub",m4)
m3.seperate()
m3.add("刷新页面")
m3.add("添加到收藏夹")
m3.add("设为首页")
m3.seperate()
m3.addLink("http://www.9499.net","9499.NET主页")
m3.addLink("http://www.9499.net?go=ly","访客留言中心")
m3.addLink("http://www.9499.net?go=tc","在线教程")
m4.add("无限级子菜单演示","sub",m5)
m4.seperate()
m4.add("刷新页面")
m4.add("添加到收藏夹")
m4.add("设为首页")
m4.seperate()
m4.addLink("http://www.9499.net","9499.NET主页")
m4.addLink("http://www.9499.net?go=ly","访客留言中心")
m4.addLink("http://www.9499.net?go=tc","在线教程")
m5.add("无限级子菜单演示","sub",m3)
m5.seperate()
m5.add("刷新页面")
m5.add("添加到收藏夹")
m5.add("设为首页")
m5.seperate()
m5.addLink("http://www.9499.net","9499.NET主页")
m5.addLink("http://www.9499.net?go=ly","访客留言中心")
m5.addLink("http://www.9499.net?go=tc","在线教程")
m3.item[1].execute=m4.item[1].execute=m5.item[1].execute=function(){self.history.go(0);}
m3.item[2].execute=m4.item[2].execute=m5.item[2].execute=function()
{
window.external.addFavorite("http://www.9499.net","创意无限,精彩无限--WWW.9499.NET");
}
m3.item[3].execute=m4.item[3].execute=m5.item[3].execute=function()
{
event.srcElement.style.behavior="url(#default#homepage)";
event.srcElement.setHomePage("http://www.9499.net");
}
/*显示右键菜单*/
document.body.oncontextmenu=function(){event.returnValue=false;}
document.body.onmousedown=function(){if(event.button==2)m3.show();}
/*显示源程序*/
var script=document.getElementsByTagName("SCRIPT")
var sCode=script[1].innerHTML
sCode=sCode.replace(//g,">")
sCode=sCode.replace(/([A-Za-z0-9> sCode=sCode.replace(/\t/g," ")
sCode=sCode.replace(/(\/\*)/g,"$1")
sCode=sCode.replace(/(\*\/)/g,"$1")
sCode=sCode.replace(/\n/g,"")
divCode.innerHTML=sCode;