跳转到内容

网页屏蔽右键菜单、F12键、复制的代码

想让自己的网站不被别人抄袭可通过以下代码来实现网页屏蔽右键菜单、F12 键、复制

JS
window.onload = function() {
  document.onkeydown = function(e) {
    var theEvent = window.event || e;
    var code = theEvent.keyCode || theEvent.which;
    if (code === 123) {
      return false;
    }
  }; //屏蔽 F12
  document.oncontextmenu = function(event) {
    if (window.event) {
      event = window.event;
    }
    try {
      var the = event.srcElement;
      if (!((the.tagName == "INPUT" && the.type.toLowerCase() == "text") || the.tagName == "TEXTAREA")) {
        return false;
      }
      return true;
    } catch (e) {
      return false;
    }
  }; //屏蔽右键菜单
  document.oncopy = function(event) {
    if (window.event) {
      event = window.event;
    }
    try {
      var the = event.srcElement;
      if (!((the.tagName == "INPUT" && the.type.toLowerCase() == "text") || the.tagName == "TEXTAREA")) {
        return false;
      }
      return true;
    } catch (e) {
      return false;
    }
  }; //屏蔽复制
}