|
其实右键菜单很简单 |
|
实现方法很简单。
不过就是只有一层 <HTML> <style> a.menuitem {text-decoration:none;color:menutext} a.menuitem:hover {background-color:highlight;color:highlighttext} div.contextmenu {background-color:threedface;border-style:outset;border-width:2;position:absolute;visibility:hidden;z-index:999} </style> <BODY> <div id=cmenu class=contextmenu> <a href="http://www.oso.com.cn/">http://www.oso.com.cn</a><br> <a href="http://www.oso.com.cn/">http://www.oso.com.cn</a><br> <a href="http://www.oso.com.cn/">http://www.oso.com.cn</a><br> <a href="http://www.oso.com.cn/">http://www.oso.com.cn</a><br> </div> </BODY> <script> function window.onbeforeunload() { cmenu.style.visibility="hidden"; } function document.onclick() { cmenu.style.visibility="hidden"; } function document.oncontextmenu() { var e=event.srcElement; var l=event.offsetX;; var t=event.offsetY; do { l+=e.offsetLeft; t+=e.offsetTop; }while(e=e.offsetParent); cmenu.style.pixelLeft=l; cmenu.style.pixelTop=t; cmenu.style.visibility="visible"; event.returnValue=false; } function cmenu.oncontextmenu() { event.cancelBubble=true; event.returnValue=false; } </script> </HTML> |