参考资料

  1. HTML 视频(Videos)播放
  2. HTML 字体, 字体颜色 ,字体大小
  3. HTML 表格表头单元格
  4. HTML 表格空间
  5. 隐形水印嵌入技术详解
  6. HTML/MarkDown互转有哪些
  7. Html转C#/JSP有哪些
  8. HTML 删除字符效果和插入字符效果

有哪些方法可以防止开发者工具被打开?

  1. 禁用右键菜单

    document.addEventListener('contextmenu', function(e) {
      e.preventDefault();
    });
  2. 禁用F12键

    document.addEventListener('keydown', function(e) {
      if (e.key === 'F12' || (e.ctrlKey && e.shiftKey && e.key === 'I')) {
        e.preventDefault();
      }
    });
  3. 禁用开发者工具快捷键

    document.addEventListener('keydown', function(e) {
      if (e.ctrlKey && e.shiftKey && (e.key === 'C' || e.key === 'J' || e.key === 'I')) {
        e.preventDefault();
      }
    });
  4. 检测窗口大小变化

    setInterval(function() {
      if (window.outerWidth - window.innerWidth > 100 || window.outerHeight - window.innerHeight > 100) {
        window.close();
      }
    }, 1000);
  5. 重写console方法

    console.log = function() {};
    console.error = function() {};
    console.warn = function() {};
  6. 禁用调试断点

    setInterval(function() {
      debugger;
    }, 1000);
  7. 检测开发者工具状态

    var devtools = /./;
    devtools.toString = function() {
      window.location.href = 'about:blank';
    };
    console.log(devtools);
  8. 禁用元素检查

    document.addEventListener('DOMNodeInserted', function(e) {
      if (e.relatedNode && e.relatedNode.nodeName === 'BODY') {
        document.body.innerHTML = '';
      }
    });
  9. 使用全屏API

    document.documentElement.requestFullscreen();
  10. 服务端检测

    if (navigator.webdriver) {
      window.location.href = 'about:blank';
    }