初学.net,关注。
帮你顶。
帮你顶。
解决方案 »
- Win32Exception (0x80004005): 拒绝访问。
- 新建的页面CS文件为什么都不带名字空间
- ASP.NET导出EXCEL时发生这样的错误...
- 关于倒计时的时间问题
- 急求购物车完美解决方案.
- 求助一个数据在页面的表示例子
- 请问怎样在网页中打开一个Word文件?
- aspx DataList控件,图片绑定后的样式问题?
- 在同一工程定义一个类调用它的方法的问题
- TreeView的Navigation问题,如何刷新框架?
- 请问那里有Crystal Enterprise Report Application Server V9.2下载?不胜感激
- 怎么样才能用客户端代码给服务器控件附值!在线等待!!
有答案通知我呀:[email protected]
是jiayuanliao(廖家远)网友提供的演示和源码。
需要自己整理一下;
我给你个思路和主要文件。
---------------------
(1)思路:
就是利用js获得点击树的节点ID。
然后描绘树菜单。
传递节点ID给一个新的页面,然后进行相应的处理。
每种不同的操作弹出不同的页面,不同的页面进行不同的操作。(2)描画菜单的文件源码:
TableColor='#0072BC';
includeSysMenu = true; //是否包含系统菜单
clientWindowLeft = 0;
clientWindowTop = 0;
function initMouseMenu(){
oSelection = document.selection;
//定义菜单层
document.write("<DIV id=MouseMenu style=\"position:absolute; left:0px; top:0px; width=150;height=20; z-index:999; visibility:hidden;\"><\/DIV>");
document.body.oncontextmenu=new Function("return ShowMouseMenu();");
document.body.onclick=new Function("MouseMenu.style.visibility='hidden';");
document.body.onscroll=new Function("MouseMenu.style.visibility='hidden';");
document.body.onselectstart=new Function("MouseMenu.style.visibility='hidden';");
window.onresizestart=new Function("MouseMenu.style.visibility='hidden';");
}
//重绘菜单
function ReDrawMouseMenu(){
//菜单高度
DivH=2;
//菜单表格头部
var DivTblTop = "<TABLE border=0 cellpadding=0 cellspacing=0 class=div2><tr><td bgcolor="+TableColor+" width=18 valign=bottom align=center bgcolor=buttonface><\/td><td bgcolor=buttonface><TABLE border=0 cellpadding=0 cellspacing=0>";
//菜单表格尾部
var DivTblBot ="<\/TABLE><\/td><\/tr><\/TABLE>";
//菜单分隔条
var HrStr="<tr><td align=center valign=middle height=2><TABLE border=0 cellpadding=0 cellspacing=0 width=128 height=2><tr><td height=1 bgcolor=buttonshadow><\/td><\/tr><tr><td height=1 bgcolor=buttonhighlight><\/td><\/tr><\/TABLE><\/td><\/tr>";
//系统导航菜单
var NavMenu=["window.history.back()\">后退","window.history.forward()\">前进"];
//系统菜单项
var SysMenu=["document.execCommand('SelectAll')\">全选","MouseMenu.style.visibility='hidden';document.execCommand('SaveAs','true')\">另存为…","location.replace('view-source:'+location.href)\">查看源文件","window.print()\">打印","window.location.reload()\">刷新"];
//菜单的顶部
var MenuTop="<tr><td align=center valign=middle height=20><TABLE border=0 cellpadding=0 cellspacing=0 width=132><tr><td valign=middle height=16 class=Mout onMouseOver=this.className='Mover'; onMouseOut=this.className='Mout'; onclick=\"";
//菜单的底部
var MenuBot="<\/td><\/tr><\/TABLE><\/td><\/tr>";
//菜单内容
var MenuStr = "";
//生成用户菜单项
for(i=0;i<arguments.length;i++){
MenuStr+=MenuTop+arguments[i]+MenuBot;
DivH+=20;
}
if(arguments.length>0 && includeSysMenu){
MenuStr+=HrStr;
DivH+=2;
}
if (includeSysMenu)
{
//如果包含系统菜单
for(i=0;i<NavMenu.length;i++){
MenuStr+=MenuTop+NavMenu[i]+MenuBot;
DivH+=20;
}
MenuStr+=HrStr; //加入分隔条
for(i=0;i<SysMenu.length;i++){
MenuStr+=MenuTop+SysMenu[i]+MenuBot;
DivH+=20;
}
}
//重绘菜单
MouseMenu.height = DivH;
MouseMenu.innerHTML = DivTblTop + MenuStr + DivTblBot;
}
if(MouseMenu.style.visibility=='visible')MouseMenu.style.visibility='hidden';
//if(event.srcElement.tagName=="A") { alert("这是链接"); return false;}
//if(event.srcElement.tagName=="IMG"&&event.srcElement.id!="menugif"||event.srcElement.tagName=="A"||event.srcElement.tagName=="TEXTAREA"||event.srcElement.tagName=="INPUT"||oSelection.type!="None")
//return true;
if(event.srcElement.tagName=="TEXTAREA"||event.srcElement.tagName=="INPUT"||oSelection.type!="None")
return true;
else{
if (event.srcElement.tagName=="treeview")
{
//alert(event.srcElement.className);
var tmpNodeID = event.treeNodeId;
NodeID = tmpNodeID;
//NodeID = tmpNodeID.substring(1,tmpNodeID.length)
includeSysMenu = true;
ReDrawMouseMenu(
"DoUrl('add');\">添加",
"DoUrl('modify');;\">修改",
"DoUrl('del');\">删除",
"DoUrl('view');\">查看"
);
}
else if (event.srcElement.tagName=="IMG")
{
var tempID = event.srcElement.id;
if (tempID.length<8 || tempID.substring(0,8)!="nodeImg_"){
return true;
}
else{
//alert(tempID);
NodeID = tempID.substring(8,tempID.length);
}
//if (event.srcElement.id=="menugif") return false;
//展开菜单
includeSysMenu = false;
ReDrawMouseMenu(
"ExpandNode();\">展开",
"ExpandAll();\">全部展开",
"CompressAll();;\">全部收缩"
);
}
else {
includeSysMenu = true;
ReDrawMouseMenu();
}
if(event.clientX+150 > document.body.clientWidth) clientWindowLeft = event.clientX+document.body.scrollLeft-150;
else clientWindowLeft = event.clientX+document.body.scrollLeft;
MouseMenu.style.left= clientWindowLeft;
if(event.clientY+DivH > document.body.clientHeight) clientWindowTop = event.clientY+document.body.scrollTop-DivH;
else clientWindowTop = event.clientY+document.body.scrollTop;
MouseMenu.style.top=clientWindowTop
MouseMenu.style.visibility='visible';
}
return false;
}
document.body.oncontextmenu=new Function("return ShowMouseMenu();");
document.body.onclick=new Function("MouseMenu.style.visibility='hidden';");
document.body.onscroll=new Function("MouseMenu.style.visibility='hidden';");
document.body.onselectstart=new Function("MouseMenu.style.visibility='hidden';");
window.onresizestart=new Function("MouseMenu.style.visibility='hidden';");
}