没有真正的右击事件
可以用js模拟:
将下面代码保存为htm看看右击效果:
+++++++++++++++++++++++++++++++++++++++++++++++++++++++
<STYLE>.skin0 {
BORDER-RIGHT: black 1px solid; BORDER-TOP: black 1px solid; VISIBILITY: hidden; BORDER-LEFT: black 1px solid; WIDTH: 160px; CURSOR: default; LINE-HEIGHT: 1px; BORDER-BOTTOM: black 1px solid; FONT-FAMILY: Verdana; POSITION: absolute; BACKGROUND-COLOR: black; TEXT-ALIGN: left
}
.skin1 {
BORDER-RIGHT: buttonhighlight 0px outset; BORDER-TOP: buttonhighlight 0px outset; FONT-SIZE: 9pt; VISIBILITY: hidden; BORDER-LEFT: buttonhighlight 0px outset; WIDTH: 120px; CURSOR: default; BORDER-BOTTOM: buttonhighlight 0px outset; FONT-FAMILY: Arial, Helvetica, sans-serif; POSITION: absolute; BACKGROUND-COLOR: #000000; TEXT-ALIGN: center
}
.menuitems {
PADDING-RIGHT: 10px; PADDING-LEFT: 10px
}
</STYLE>
<SCRIPT language=JavaScript1.2>
<!-- Begin
var menuskin = "skin1"; // skin0, or skin1
var display_url = 0; // Show URLs in status bar?
function showmenuie5() {
var rightedge = document.body.clientWidth-event.clientX;
var bottomedge = document.body.clientHeight-event.clientY;
if (rightedge < ie5menu.offsetWidth)
ie5menu.style.left = document.body.scrollLeft + event.clientX - ie5menu.offsetWidth;
else
ie5menu.style.left = document.body.scrollLeft + event.clientX;
if (bottomedge < ie5menu.offsetHeight)
ie5menu.style.top = document.body.scrollTop + event.clientY - ie5menu.offsetHeight;
else
ie5menu.style.top = document.body.scrollTop + event.clientY;
ie5menu.style.visibility = "visible";
return false;
}
function hidemenuie5() {
ie5menu.style.visibility = "hidden";
}
function highlightie5() {
if (event.srcElement.className == "menuitems") {
event.srcElement.style.backgroundColor = "highlight";
event.srcElement.style.color = "white";
if (display_url)
window.status = event.srcElement.url;
}
}
function lowlightie5() {
if (event.srcElement.className == "menuitems") {
event.srcElement.style.backgroundColor = "";
event.srcElement.style.color = "black";
window.status = "";
}
}
function jumptoie5() {
if (event.srcElement.className == "menuitems") {
if (event.srcElement.getAttribute("target") != null)
window.open(event.srcElement.url, event.srcElement.getAttribute("target"));
else
window.location = event.srcElement.url;
}
}
//  End -->
</SCRIPT>
<DIV class=skin0 id=ie5menu onmouseover=highlightie5()
style="LEFT: 280px; TOP: 28px" onclick=jumptoie5(); onmouseout=lowlightie5()>
<DIV>
<TABLE height="97%" cellSpacing=1 cellPadding=0 width="98%" align=center
bgColor=#000000>
<TBODY>
<TR>
<TD
onmouseover="this.style.backgroundColor='#999900'; this.style.cursor='hand';"
onmouseout="this.style.backgroundColor='#99cc33';" bgColor=#99cc00 height=20
scroll="no" onload="window.defaultStatus='00009876.4567.net';">
<CENTER>::欢迎你的光临:: </CENTER></TD></TR>
<TR>
<TD
onmouseover="this.style.backgroundColor='#ff9900'; this.style.cursor='e-resize';"
onmouseout="this.style.backgroundColor='#ffcc00';" bgColor=#ffcc00
height=20>
<CENTER>::
<SCRIPT language=JavaScript>function bookit(){window.external.addFavorite('http://www.333v.com','→::资源网::')}if (document.all)document.write('<a href="#" onClick="bookit()">加入收藏</a>')</SCRIPT>
:: </CENTER></TD></TR>
<TR>
<TD
onmouseover="this.style.backgroundColor='#ff9900'; this.style.cursor='e-resize';"
onmouseout="this.style.backgroundColor='#ffffff';" vAlign=center
bgColor=#ffffff>
<CENTER>::<A href="http://www.333v.com/" target=_blank>资源网</A>::
</CENTER></TD></TR><TR>
<TD
onmouseover="this.style.backgroundColor='#ff9900'; this.style.cursor='e-resize';"
onmouseout="this.style.backgroundColor='#ffcc00';" vAlign=center
bgColor=#ffcc00>
<CENTER>::<A [email protected]
href="mailto:[email protected]">写信给我</A>:: </CENTER></TD></TR></TBODY></TABLE></DIV></DIV>
<SCRIPT language=JavaScript1.2>
if (document.all && window.print) {
ie5menu.className = menuskin;
document.oncontextmenu = showmenuie5;
document.body.onclick = hidemenuie5;
}
</SCRIPT>

解决方案 »

  1.   

    <iewc:TreeView id="TreeView1" runat="server"
       oncontextmenu="ShowTreeViewMenu();"
    />
    客户端JavaScript函数:
    <script language="javascript">
    function ShowTreeViewMenu()
    {
        var nodeindex = event.treeNodeIndex;
        if (typeof(nodeindex) == "undefined")
            return;
        //接下来你就可以根据节点显示菜单了
    }
      

  2.   

    zhouqiufang(诺兰):菜单如何写?
    你有具体的一段代码吗?
      

  3.   

    顶zhouqiufang(诺兰)大哥帮忙.我们小吓要看.