5D艺术网首页
商城
|
资讯
|
作品
|
博客
|
教程
|
论坛
登录
注册
加为好友
发短消息
来自:郑州
性别:先生
最后登录:2011-04-27
http://wwle.5d.cn/
我有一对翅膀,不是用来飞翔,而是用来煮汤。
首页
|
新闻
|
话题
|
博客
|
相册
|
艺术作品
|
社交关系
|
留言板
|
社交圈
2005/08/18 | jsMenu
类别(网页类学习笔记)
|
评论
(0)
|
阅读(103)
|
发表于 09:56
用的是Stedysoft的2k3Menu里的图片,css,及3个htc:2k3MenuBar.htc,2k3Menu.htc,2k3MenuRoot.htc
2.需要修改的地方就是 将 2k3MenuRoot.htc 里的 <PUBLIC:property name="menu" value /> 修改为<PUBLIC:property name="subMenu" value />,然后将给htc有关menu的都改为subMenu;
3.我修改的js脚本如下:
var oMenubar;
//Nodes.Add("R",4,"P3","Item0");
//Add(null,0,"R","Root");
/*
功能:添加菜单项
参数:
parentItem: 上级节点的ID,如果为null,则为第一菜单项
level : 菜单级别。
0:第一条
1:最后条
2:下一条
3:上一条
4:子菜单
item : 菜单id
itemName : 菜单名称
example:
插入第一个菜单 addItem(null,0,"item1","我是第一个菜单");
*/
function addItem(parentItem,level,item,itemName,itemTitle,itemClick,imageSrc){
//添加MenuRoot
if ((parentItem=="null")||(level==0)){
//添加一个MenuBar
oMenubar = document.all.item("_MenuBar").firstChild.firstChild;
var oItem=oMenubar.insertCell(oMenubar.cells.length - 1);
with (oItem){
id=item;
Height="25";
noWrap=true;
className="2k3MenuRoot";
//title=itemTitle;
innerHTML="<div class=\"2k3MenuRootCaption\" >"+itemName+"</div>";
}
}
//添加子菜单
if ((parentItem!="null")||(parentItem!="")){
if (level==4){
var oSubMenuItem="_SubMenu_"+parentItem;
var oParentMenu=document.all.item(parentItem);
//如果找不到父菜单
if (oParentMenu==null){
return;
}
var oSubMenu=document.all.item(oSubMenuItem);
if (oSubMenu==null){
createMenu(oSubMenuItem);
oSubMenu=document.all.item(oSubMenuItem);
//return;
document.all.item(parentItem).subMenu=oSubMenuItem;
}
//不是MenuRoot,则添加箭头
if (oParentMenu.className!="2k3MenuRoot"){
oParentMenu.cells(oParentMenu.cells.length - 2).className="2k3MenuMore";
}
//添加一行分割线
if (itemName=="-"){
var oRow=oSubMenu.tBodies(0).insertRow();
with (oRow){
className="2k3MenuSeperator";
var oCell=insertCell();
oCell.className="2k3MenuImage";
oCell.colSpan="2";
oCell=insertCell();
oCell.className="2k3MenuCaption";
oCell.colSpan="3";
oCell.innerHTML="<IMG>";
}
}else if(itemName!=null){
var oRow=oSubMenu.tBodies(0).insertRow();
with (oRow){
className="2k3MenuItem";
id=item;
title=itemTitle;
var oCell=insertCell();
oCell.clsssName="2k3MenuVerticalSpacerLeft";
oCell=insertCell();
oCell.className="2k3MenuImage";
oCell.innerHTML="<img src="+imageSrc+" width=\"16\" height=\"16\">";
oCell=insertCell();
oCell.className="2k3MenuCaption";
oCell.innerText=itemName;
oCell=insertCell();
oCell.className="2k3MenuNoMore";
oCell.innerText="4";
oCell=insertCell();
oCell.className="2k3MenuVerticalSpacerRight";
}
}
}
}
}
function createMenubar(){
var htmlstr="<table class=\"2k3MenuBar\" id=\"_MenuBar\" cellspacing=0 cellpadding=0 width=100% height=20>";
htmlstr+=" <tr>";
htmlstr+=" <td class=2k3MenuBarHandle></td>";
//htmlstr+=" <td class=\"2k3MenuRoot\" id=\"_mnuRoot1\" ><div class=\"2k3MenuRootCaption\">File</div></td>";
htmlstr+=" <td width=100%></td>";
htmlstr+=" </tr>";
htmlstr+="</table>";
document.write(htmlstr);
}
function createMenu(item){
var htmlstr;
htmlstr="<table class=\"2k3Menu\" id="+item+" cellspacing=\"0\" cellpadding=\"0\">";
htmlstr+=" <thead><tr><td colspan=\"5\"><div class=\"2k3MenuRootConnector\"></div></td></tr></thead>";
htmlstr+=" <tbody>";
htmlstr+=" </tbody>";
htmlstr+=" <tfoot><tr><td colspan=\"5\"></td></tr></tfoot>";
htmlstr+="</table>";
document.write(htmlstr);
}
//document.onclick=function{
// if event.
//}
function doClick(){
var el=window.event.srcElement;
if (el.parentElement.className=="2k3MenuImage"){
el=el.parentElement.parentElement;
}else if ((el.className=="2k3MenuVerticalSpacerLeft")|(el.className=="2k3MenuCaption")|(el.className=="2k3MenuNoMore")|(el.className=="2k3MenuVerticalSpacerRight")){
el=el.parentElement;
}else{
return
}
//alert(el.className);
if ((el.className=="2k3MenuItem")|(el.className=="2k3MenuItemOver")){
alert(el.id);
}
}
5.举例应用。
<Script language="javascript">
createMenubar();
addItem(null,0,"m_System","系统","系统设置",null,null);
addItem("m_System",4,"m_SkinSetting","界面设置","根据自己的喜好来配置界面","demo()",null);
addItem("m_SkinSetting",4,"m_SkinSetting1","界面设置1","根据自己的喜好来配置界面","demo()",null);
addItem("m_SkinSetting",4,"m_SkinSetting2","界面设置2","根据自己的喜好来配置界面","demo()",null);
addItem("m_SkinSetting",4,"m_SkinSetting3","界面设置3","根据自己的喜好来配置界面","demo()",null);
addItem("m_System",4,"m_ChangePwd","修改密码","修改用户的登陆密码","demo()",null);
addItem("m_System",4,"-","-","-","demo()",null);
addItem("m_System",4,"m_ReLogin","重新登陆","更换其它用户名登录","demo()",null);
addItem("m_System",4,"m_Exit","退出","退出系统","demo()",null);
addItem("m_Exit",4,"m_Exit01","退出子菜单","退出系统","demo()",null);
addItem("m_Exit",4,"m_Exit02","退出子菜单1","退出系统","demo()",null);
</script>
4.效果如图:
作者Blog:http://blog.csdn.net/juwuyi/
0
评论
Comments
日志分类
首页
[289]
教程习题
[21]
数据库学习笔记
[60]
语言类学习笔记
[75]
网页类学习笔记
[93]
其他相关笔记
[40]