정보실

웹학교

정보실

javascript 브라우저 개발자도구 열린 것 인식하기

본문

https://dev.to/composite/a-simple-way-to-detect-devtools-2ag0 


https://jsfiddle.net/evnrorea/embedded/result/ 


<script>

!function() {

function detectDevTool(allow) {

  if(isNaN(+allow)) allow = 100;

    var start = +new Date();

    debugger;

    var end = +new Date();

    if(isNaN(start) || isNaN(end) || end - start > allow) {

    alert('DEVTOOLS detected. all operations will be terminated.');

      document.write('DEVTOOLS detected.');

    }

  }

  if(window.attachEvent) {

  if (document.readyState === "complete" || document.readyState === "interactive") {

    detectDevTool();

      window.attachEvent('onresize', detectDevTool);

      window.attachEvent('onmousemove', detectDevTool);

      window.attachEvent('onfocus', detectDevTool);

      window.attachEvent('onblur', detectDevTool);

    } else {

    setTimeout(argument.callee, 0);

    }

  } else {

  window.addEventListener('load', detectDevTool);

    window.addEventListener('resize', detectDevTool);

    window.addEventListener('mousemove', detectDevTool);

    window.addEventListener('focus', detectDevTool);

    window.addEventListener('blur', detectDevTool);

  }

}();

</script>

페이지 정보

조회 11회 ]  작성일20-03-21 10:39

웹학교