1.自定义右键菜单:

 1 <!DOCTYPE HTML>
 2 <html>
 3 <head>
 4 <meta charset="utf-8">
 5 <title>无标题文档</title>
 6 <style>
 7 * {margin:0; padding:0; list-style:none;}
 8 #div1 {position:absolute; width:80px; background:#CCC; border:1px solid black; display:none;}
 9 </style>
10 <script>
11 document.oncontextmenu=function (ev)
12 {
13     var oEvent=ev||event;
14     var oDiv=document.getElementById('div1');
15     
16     oDiv.style.display='block';
17     oDiv.style.left=oEvent.clientX+'px';
18     oDiv.style.top=oEvent.clientY+'px';
19     
20     return false;
21 };
22 
23 document.onclick=function ()
24 {
25     var oDiv=document.getElementById('div1');
26     
27     oDiv.style.display='none';
28 };
29 </script>
30 </head>
31 <body>
32 <div id="div1">
33     <ul>
34         <li>aaa</li>
35         <li>bbb</li>
36         <li>ccc</li>
37         <li>ddd</li>
38     </ul>
39 </div>
40 </body>
41 </html>
View Code

相关文章:

  • 2021-09-02
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-05-19
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案