html屏蔽鼠标右键

 1 <!doctype html>
 2 <html lang="en">
 3  <head>
 4   <meta charset="UTF-8">
 5   <meta name="Generator" content="EditPlus®">
 6   <meta name="Author" content="">
 7   <meta name="Keywords" content="">
 8   <meta name="Description" content="">
 9   <title>Document</title>
10  </head>
11  <body>
12     <script type="text/javascript">
13         document.oncontextmenu = function() {
14              return false;
15         }
16         
17          //  左键是1 滑轮是2 右键是3
18         document.addEventListener("mousedown",function(e){
19             alert(e.which);
20         },false);
21         
22         // jquery 方式
23         $(document).mousedown(function(e){
24             var key = e.which;
25             if(key == 3){
26                 alert("这个事鼠标右键");
27             }else{
28                 alert(key);
29             }
30         });
31     </script>
32  </body>
33 </html>

 

posted @ 2016-01-08 19:25  幸福流浪  阅读(605)  评论(0编辑  收藏  举报