殷德瑶博客
喜欢的歌,静静地听!喜欢的人,远远地看!

防止别人查看页面的代码,用来保护网站版权

殷德瑶 2016-8-1 emlog教程 评论 2717 次

代码如下:

<!--onselectstart:禁止选中 oncontextmenu:右键弹出版权 event.keyCode==27:按esc键表示放弃Esc键阻止网页继续载入,也就是说你按ESC键网页还是继续加载--><body onselectstart="return false;" oncontextmenu="alert('请尊重本网站版权!');return false;" onkeydown="if(event.keyCode==27) return false;"><script type="text/javascript">document.onmousedown = click; //绑定禁用鼠标右键事件document.onkeydown = ctrl_key; //绑定禁用键盘事件function click() {if (event.button == 2) //单击的鼠标键为右键{alert('请尊重本网站版权!');return false;}}function ctrl_key() {if (event.keyCode == 17) { //禁用CTRL+S 保存网页代码window.alert("请尊重本网站版权!");return false;} if (event.keyCode == 123) { //禁用F12查看源代码alert('请尊重本网站版权!');return false;}}</script> <script>function fuckyou(){ window.close(); //关闭当前窗口(防抽) window.location="about:blank"; //将当前窗口跳转置空白页 } function ck() { console.profile(); console.profileEnd(); //我们判断一下profiles里面有没有东西,如果有,肯定有人按F12了,没错!! if(console.clear) { console.clear() }; if (typeof console.profiles =="object"){ return console.profiles.length > 0; } } function hehe(){ if( (window.console && (console.firebug || console.table && /firebug/i.test(console.table()) )) || (typeof opera == 'object' && typeof opera.postError == 'function' && console.profile.length > 0)){ fuckyou(); } if(typeof console.profiles =="object"&&console.profiles.length > 0){ fuckyou(); } } hehe(); window.onresize = function(){ if((window.outerHeight-window.innerHeight)>200) //判断当前窗口内页高度和窗口高度,如果差值大于200,那么呵呵 fuckyou(); }</script> 

发表评论


粤ICP备15078261号 Powered by 黑暗之夜
Theme by 殷德瑶博客