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 }