在有些页面不想让用户访问F12的情况下我们需要如何去处理,要如何实现用户访问F12关闭网页或进行跳转。
下面具体贴上代码 复制到你的网页代码中即可
关闭窗口并打开空白页JS代码
| 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 | <script type="text/javascript"> //判断F12审查元素 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-网页跳转JS
| 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 | function collect() {     //开始javascript执行过程的数据收集     console.profile();     //配合profile方法,作为数据收集的结束     console.profileEnd();     //我们判断一下profiles里面有没有东西,如果有,肯定有人按F12了,没错!!       if (console.clear) {         //清空控制台         console.clear()     };     if (typeof console.profiles == "object") {         return console.profiles.length > 0;     } } function check() {     if ((window.console && (console.firebug || console.table && /firebug/i.test(console.table()))) || (typeof opera == 'object' && typeof opera.postError == 'function' && console.profile.length > 0)) {         jump();     }     if (typeof console.profiles == "object" && console.profiles.length > 0) {         jump();     } } check(); window.onresize = function() {     //判断当前窗口内页高度和窗口高度     if ((window.outerHeight - window.innerHeight) > 200)     jump(); } function jump() {     window.location = "https://72.rs"; | 
本文来自毅常's World ,本文观点不代表蓝洛水深立场,转载请联系原作者。
 
                
 微信扫一扫
                                                            微信扫一扫                                                     支付宝扫一扫
                                                            支付宝扫一扫                                                     
            