前言
自己辛苦做的网站,著作权归作者所有。为避免被他人窃取并进行商业化,就需要把网站进一步限制
禁用F12、禁用调试工具、屏蔽右键菜单、屏蔽选中、屏蔽复制、屏蔽剪贴、屏蔽粘贴
屏蔽及禁用代码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130
|
window.onkeydown = window.onkeyup = window.onkeypress = function (event) { if (event.keyCode == 123) { event.preventDefault(); window.event.returnValue = false; } }
var threshold = 160;
var check = setInterval(function() { if (window.outerWidth - window.innerWidth > threshold || window.outerHeight - window.innerHeight > threshold) { window.location.reload(); } }, 1000)
document.oncontextmenu = function (event){ if(window.event){ event = window.event; } try{ var the = event.srcElement; if (!((the.tagName == "INPUT" && the.type.toLowerCase() == "text") || the.tagName == "TEXTAREA")){ return false; } return true; } catch (e){ return false; } }
document.onselectstart = function (event){ if(window.event){ event = window.event; } try{ var the = event.srcElement; if (!((the.tagName == "INPUT" && the.type.toLowerCase() == "text") || the.tagName == "TEXTAREA")){ return false; } return true; } catch (e) { return false; } }
document.oncopy = function (event){ if(window.event){ event = window.event; } try{ var the = event.srcElement; if(!((the.tagName == "INPUT" && the.type.toLowerCase() == "text") || the.tagName == "TEXTAREA")){ return false; } return true; } catch (e){ return false; } }
document.oncut = function (event){ if(window.event){ event = window.event; } try{ var the = event.srcElement; if(!((the.tagName == "INPUT" && the.type.toLowerCase() == "text") || the.tagName == "TEXTAREA")){ return false; } return true; } catch (e){ return false; } }
document.onpaste = function (event){ if(window.event){ event = window.event; } try{ var the = event.srcElement; if (!((the.tagName == "INPUT" && the.type.toLowerCase() == "text") || the.tagName == "TEXTAREA")){ return false; } return true; } catch (e){ return false; } }
|
温馨提示
- 关于
屏蔽选中文字
,搭配下面这段css更具有奇效1 2 3 4 5 6 7 8 9
| <style> /* 文字禁止选中 */ #footer, #header { -webkit-user-select:none; -moz-user-select:none; -ms-user-select:none; user-select:none; } </style>
|