禁止F12的两种方法

网站需要禁止F12,找了两种方法

一:

 1 <script>
 2     function fuckyou() {
 3         window.close(); //关闭当前窗口(防抽)
 4         window.location = "about:blank"; //将当前窗口跳转置空白页
 5     }
 6 
 7     function ck() {
 8         console.profile();
 9         console.profileEnd();
10         //我们判断一下profiles里面有没有东西,如果有,肯定有人按F12了,没错!!
11         if (console.clear) {
12             console.clear()
13         };
14         if (typeof console.profiles == "object") {
15             return console.profiles.length > 0;
16         }
17     }
18 
19     function hehe() {
20         if ((window.console && (console.firebug || console.table && /firebug/i.test(console.table()))) || (typeof opera == 'object' && typeof opera.postError == 'function' && console.profile.length > 0)) {
21             fuckyou();
22         }
23         if (typeof console.profiles == "object" && console.profiles.length > 0) {
24             fuckyou();
25         }
26     }
27     hehe();
28     window.onresize = function() {
29         if ((window.outerHeight - window.innerHeight) > 200)
30         //判断当前窗口内页高度和窗口高度,如果差值大于200,那么呵呵
31             fuckyou();
32     }
33     </script>

二:在body中插入:

 1 <body oncontextmenu="return false" onselectstart="return false"> 

  

posted @ 2017-06-02 14:35  echo_hello  阅读(3184)  评论(1编辑  收藏  举报