编辑右键菜单--换成自己需要的菜单
<!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8"> <title></title> <style> *{margin:0;padding:0;list-style:none;} #div1{position:absolute;width:100px; top:0; left:0; background:red;display: none;} </style> </head> <body> <div id="div1"> <ul> <li><a href="#">11111111</a></li> <li>11111111</li> <li>11111111</li> <li>11111111</li> <li>11111111</li> <li>11111111</li> <li>11111111</li> </ul> </div> </body> </html>
<script> document.oncontextmenu=function(e){ var even=e||event; var oDiv=document.getElementById("div1"); oDiv.style.display="block"; oDiv.style.left= e.clientX+"px"; oDiv.style.top= e.clientY+"px"; document.onclick=function(){ var oDiv=document.getElementById("div1"); oDiv.style.display="none"; }; return false; }; </script>