有个神奇的东西叫做审查元素,按下神奇的F12,就是见证奇迹的时刻。审查元素真的是一个强大功能,有的时候看中别人网站的某个样式做的比较好,按下F12审查元素来查看别人的代码,统统扒过来。那么如果防止别人查看自己网站的代码,扒代码呢,当然,也只是防新手而已~心理安慰~
一、防F12扒代码:按下F12关闭当前页面
使用方法:将代码添加到网页顶部或底部即可,高手一般能破解,哈哈。
<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>
二、防F12扒代码:按下F12画面卡死
使用方法:将代码添加到网页顶部或底部即可,这个也能破解,感觉这个更牛一点。
<script type="text/Javascript"> function inlobase_noF12(){while(1){}} function inlojv_console(){if((window.console&&(console.firebug||console.table&&/firebug/i.test(console.table())))||(typeof opera=="object"&&typeof opera.postError=="function"&&console.profile.length>0)){inlobase_noF12()}if(typeof console.profiles=="object"&&console.profiles.length>0){inlobase_noF12()}}inlojv_console();window.onresize=function(){if((window.outerHeight-window.innerHeight)>200){inlobase_noF12()}}; </script>
三、屏蔽各种扒站的可疑操作。
把这段js代码加到你网页上,即可屏蔽鼠标右键菜单、复制粘贴、选中等。
<script> //屏蔽右键菜单 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.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; } } //屏蔽复制 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.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; } } </script>
声明:本站所有文章均来源于网络,本站不提供任何的技术帮助,除亲测源码外均未进行测试,并不保证能完美运行,如有问题请联系相关人员进行处理。如有侵权请联系及时站长进行删除。