联接的自定义右键菜单

[入库:2005年8月18日] [更新:2007年3月25日]

本文简介:选择自 jiangzheng3 的 blog

<html>
<head>
<title>右键菜单</title>
</head>
<body>
<script  language=javascript1.2>
//program by jiangzheng3 
//hongceng_3@hotmail.com
function shonone() //使关联菜单失效
{
return false;
}
function tt(msg)  //自定义处理函数  msg处理的关键字哦
{
  if(event.button != 2)  //如果不是右键就不处理
     {return false;}
  else
  { 
    aaavm.innerhtml="<a href='" + msg + ".htm'>" + msg + "</a>";
    msgdiv.style.left=event.clientx+20;
    msgdiv.style.top=event.clienty;
    msgdiv.style.display = "block";
  } 
}

function mnone()  //隐藏菜单
{
 msgdiv.style.display = "none";
}
</script>

<script  language=javascript1.2>
if  (document.all  &&  window.print)  {
document.oncontextmenu  =  shonone; //使关联菜单失效的函数,不可直接用return false;
document.body.onclick  =  mnone;   //隐藏菜单
}
</script>
<a href="aa.htm" onmousedown="tt('aaa')" onclick="return false">不可直接打开链接一</a><br>
<a href="bb.htm" onmousedown="tt('bbb')" onclick="return false">不可直接打开链接二</a><br>
<a href="cc.htm" onmousedown="tt('ccc')" onclick="return false">不可直接打开链接三</a><br>
<a href="ee.htm" onmousedown="tt('eee')">可直接打开链接四</a><br>
<div id="msgdiv" style="position:absolute;display: none">
<div>
<table border="0" cellpadding="1" cellspacing="1" bgcolor="#000000">
<tr bgcolor="#cccccc">
   <td>菜单</td>
</tr>
<tr bgcolor="#cccccc">
   <td><div id="aaavm"></div></td>
</tr>
<tr bgcolor="#cccccc">
   <td>关闭</td>
</tr>
</table> 
</div>
</div>
</body>
</html>

可用于树型菜单,当然这只是最初的.大家可以根据自己的情况改写,实现您的功能.

本文关键:联接,右键菜单,树型菜单
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top