联接的自定义右键菜单

王朝other·作者佚名  2006-01-09
窄屏简体版  字體: |||超大  

<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>

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

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航