JavaScript 에서 콘 솔 열기 금지 (오른쪽 키 / 도구 모음 / F12 / Shift + Ctrl + I)

인터넷 에서 찾 는 많은 코드 는 쓸모 가 없다. wangning 1125 블 로그 에서 아래 코드 테스트 가 유효 하 다 는 것 을 발견 하여 공유 합 니 다.먼저 원본 코드 를 아래 에 놓 으 세 요.
 
 
 
     
     
    <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>  

  
 
    <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> 
 
</code></pre> 
  <p> </p> 
  <p>             ,    “                 ”                             ,               (        :JavaScript          、  、  ),                    ,          ,         。。。                             ,              footer.php     ,                      :</p> 
  <p> </p> 
  <pre><code><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"; 
        } 
    } 
</script> </code></pre> 
  <p>      JavaScript  ,             JavaScript        ,                        。</p> 
 </div> 
</div>
                            </div>
                        </div>

좋은 웹페이지 즐겨찾기