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

 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     }

 

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。