码迷,mamicode.com
首页 > Web开发 > 详细

JS屏蔽右键菜单,复制,粘帖xxxxx........

时间:2015-04-01 17:11:23      阅读:114      评论:0      收藏:0      [点我收藏+]

标签:

 1 //屏蔽右键菜单
 2     document.oncontextmenu = function (event) {
 3         if (window.event) {
 4             event = window.event;
 5         } try {
 6             var the = event.srcElement;
 7             if (!((the.tagName == "INPUT" && the.type.toLowerCase() == "text") || the.tagName == "TEXTAREA")) {
 8                 return false;
 9             }
10             return true;
11         } catch (e) {
12             return false;
13         }
14     }
15 
16     //屏蔽粘贴
17     document.onpaste = function (event) {
18         if (window.event) {
19             event = window.event;
20         } try {
21             var the = event.srcElement;
22             if (!((the.tagName == "INPUT" && the.type.toLowerCase() == "text") || the.tagName == "TEXTAREA")) {
23                 return false;
24             }
25             return true;
26         } catch (e) {
27             return false;
28         }
29     }
30 
31     //屏蔽复制
32     document.oncopy = function (event) {
33         if (window.event) {
34             event = window.event;
35         } try {
36             var the = event.srcElement;
37             if (!((the.tagName == "INPUT" && the.type.toLowerCase() == "text") || the.tagName == "TEXTAREA")) {
38                 return false;
39             }
40             return true;
41         } catch (e) {
42             return false;
43         }
44     }
45 
46     //屏蔽剪切
47     document.oncut = function (event) {
48         if (window.event) {
49             event = window.event;
50         } try {
51             var the = event.srcElement;
52             if (!((the.tagName == "INPUT" && the.type.toLowerCase() == "text") || the.tagName == "TEXTAREA")) {
53                 return false;
54             }
55             return true;
56         } catch (e) {
57             return false;
58         }
59     }
60 
61     //屏蔽选中
62     document.onselectstart = function (event) {
63         if (window.event) {
64             event = window.event;
65         } try {
66             var the = event.srcElement;
67             if (!((the.tagName == "INPUT" && the.type.toLowerCase() == "text") || the.tagName == "TEXTAREA")) {
68                 return false;
69             }
70             return true;
71         } catch (e) {
72             return false;
73         }
74     }

 

JS屏蔽右键菜单,复制,粘帖xxxxx........

标签:

原文地址:http://www.cnblogs.com/lyghost/p/4383953.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!