常见鼠标事件

contextmenu主要控制应该如何显示上下文菜单,主要用于程序员取消默认的上下文菜单。

 1 <!DOCTYPE html>
 2 <html>
 3     <head>
 4         <meta charset="utf-8">
 5         <title></title>
 6     </head>
 7     <body>
 8         我是一段不愿分享的文字
 9         <script>
10             // 1.contextmenu我们可以禁用右键菜单
11             document.addEventListener('contextmenu', function(e) {
12                 e.preventDefault();
13             });
14             // 禁止选中文字
15             document.addEventListener('selectstart', function(e) {
16                 e.preventDefault();
17             })
18         </script>
19     </body>
20 </html>

 

posted @ 2020-05-24 15:20  鼓舞飞扬  阅读(151)  评论(0编辑  收藏  举报