Back

绕过禁用F12

生活小妙招

今天做题的时候,遇到了这个,一按F12,就弹出hacker

以前还真没遇见过,搜了一下,原来是js

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
    <title></title> 
    <style type="text/css"> 
    /*禁止选中文字*/ 
    body{ 
        -moz-user-select: none; /*火狐*/ 
        -webkit-user-select: none; /*webkit浏览器*/ 
        -ms-user-select: none; /*IE10*/ 
        -khtml-user-select: none; /*早期浏览器*/ 
        user-select: none; 
    } 
    </style>  
</head>
  
<body> 
    <p>Test</p> 
<script type='text/javascript'> 
    //禁用右键(防止右键查看源代码) 
    window.oncontextmenu=function(){return false;} 
    //禁止任何键盘敲击事件(防止F12和shift+ctrl+i调起开发者工具) 
    window.onkeydown = window.onkeyup = window.onkeypress = function () { 
        window.event.returnValue = false; 
        return false; 
    } 
    //如果用户在工具栏调起开发者工具,那么判断浏览器的可视高度和可视宽度是否有改变,如有改变则关闭本页面 
    var h = window.innerHeight,w=window.innerWidth; 
    window.onresize = function () { 
        if (h!= window.innerHeight||w!=window.innerWidth){ 
            window.close(); 
            window.location = "about:blank"; 
        } 
    } 
    /*好吧,你的开发者工具是单独的窗口显示,不会改变原来网页的高度和宽度, 但是你只要修改页面元素我就重新加载一次数据,让你无法修改页面元素(不支持IE9以下浏览器)*/ 
    if(window.addEventListener){ 
        window.addEventListener("DOMCharacterDataModified", function(){window.location.reload();}, true); 
        window.addEventListener("DOMAttributeNameChanged", function(){window.location.reload();}, true); 
        window.addEventListener("DOMCharacterDataModified", function(){window.location.reload();}, true); 
        window.addEventListener("DOMElementNameChanged", function(){window.location.reload();}, true); 
        window.addEventListener("DOMNodeInserted", function(){window.location.reload();}, true); 
        window.addEventListener("DOMNodeInsertedIntoDocument", function(){window.location.reload();}, true); 
        window.addEventListener("DOMNodeRemoved", function(){window.location.reload();}, true); 
        window.addEventListener("DOMNodeRemovedFromDocument", function(){window.location.reload();}, true); 
        window.addEventListener("DOMSubtreeModified", function(){window.location.reload();}, true); 
    } 
</script> 
</body> 
</html>

JavaScript 实现禁止打开控制台(右键/工具栏/F12/Shift+Ctrl+I)

判断浏览器的可视高度和可视宽度是否有改变,清奇的思路。

把开发者工具是单独的窗口显示就好。

还有,就是先造个本地网站的404页面,在那里把开发者工具打开,然后再回来。

还有可以试试:

ctrl+shift+i

ctrl+shift+j

ctrl+u

Licensed under CC BY-NC-SA 4.0
comments powered by Disqus
Built with Hugo
Theme Stack designed by Jimmy
© Licensed Under CC BY-NC-SA 4.0