JS禁止F12和鼠标右键代码

 4592

一共两块代码 一个禁止F12和鼠标右键代码 代码可以禁止别人F12和鼠标右键代码 可以防止别人偷去你的代码和你的源码

  1. //禁止右键
  2. function click(e) {
  3.     if (document.all) {
  4.         if (event.button == 2 || event.button == 3) {
  5.             alert("禁止恶意拿代码的");
  6.             oncontextmenu = "return false";
  7.         }
  8.     }
  9.     if (document.layers) {
  10.         if (e.which == 3) {
  11.             oncontextmenu = "return false";
  12.         }
  13.     }
  14. }
  15. if (document.layers) {
  16.     document.captureEvents(Event.MOUSEDOWN);
  17. }
  18. document.onmousedown = click;
  19. document.oncontextmenu = new Function("return false;");
  20. document.onkeydown = document.onkeyup = document.onkeypress = function() {
  21.     if (window.event.keyCode == 12) {
  22.         window.event.returnValue = false;
  23.         return false;
  24.     }
  25. };
  1. //禁止F12
  2. function fuckyou() {
  3.     window.close();
  4.     //关闭当前窗口(防抽)
  5.     window.location = "about:blank";
  6. }
  7. function click(e) {
  8.     if (document.all) {
  9.         if (event.button == 2 || event.button == 3) {
  10.             alert("禁止恶意拿代码的");
  11.             oncontextmenu = "return false";
  12.         }
  13.     }
  14.     if (document.layers) {
  15.         if (e.which == 3) {
  16.             oncontextmenu = "return false";
  17.         }
  18.     }
  19. }
  20. if (document.layers) {
  21.     fuckyou();
  22.     document.captureEvents(Event.MOUSEDOWN);
  23. }
  24. document.onmousedown = click;
  25. document.oncontextmenu = new Function("return false;");
  26. document.onkeydown = document.onkeyup = document.onkeypress = function() {
  27.     if (window.event.keyCode == 123) {
  28.         fuckyou();
  29.         window.event.returnValue = false;
  30.         return false;
  31.     }
  32. };


本文网址:https://www.zztuku.com/index.php/detail-7651.html
站长图库 - JS禁止F12和鼠标右键代码
申明:如有侵犯,请 联系我们 删除。

评论(0)条

您还没有登录,请 登录 后发表评论!

提示:请勿发布广告垃圾评论,否则封号处理!!

    编辑推荐