孟垂博自媒体博客|只做精品

首页 > 网站教程 > js效果  >  禁止F12和鼠标右键代码
  1. <script>//禁止右键
  2. function click(e) {
  3. if (document.all) {
  4. if (event.button==2||event.button==3) { alert("禁止恶意拿代码的");
  5. oncontextmenu='return false';
  6. }
  7. }
  8. if (document.layers) {
  9. if (e.which == 3) {
  10. oncontextmenu='return false';
  11. }
  12. }
  13. }
  14. if (document.layers) {
  15. document.captureEvents(Event.MOUSEDOWN);
  16. }
  17. document.onmousedown=click;
  18. document.oncontextmenu = new Function("return false;")
  19. document.onkeydown =document.onkeyup = document.onkeypress=function(){
  20. if(window.event.keyCode == 12) {
  21. window.event.returnValue=false;
  22. return(false);
  23. }
  24. }
  25. </script>
  26. <script>//禁止F12
  27. function fuckyou(){
  28. window.close(); //关闭当前窗口(防抽)
  29. window.location="about:blank"; //将当前窗口跳转置空白页
  30. }
  31.  
  32. function click(e) {
  33. if (document.all) {
  34. if (event.button==2||event.button==3) {
  35. alert("禁止恶意拿代码的");
  36. oncontextmenu='return false';
  37. }
  38.  
  39. }
  40. if (document.layers) {
  41. if (e.which == 3) {
  42. oncontextmenu='return false';
  43. }
  44. }
  45. }
  46. if (document.layers) {
  47. fuckyou();
  48. document.captureEvents(Event.MOUSEDOWN);
  49. }
  50. document.onmousedown=click;
  51. document.oncontextmenu = new Function("return false;")
  52. document.onkeydown =document.onkeyup = document.onkeypress=function(){
  53. if(window.event.keyCode == 123) {
  54. fuckyou();
  55. window.event.returnValue=false;
  56. return(false);
  57. }
  58. }
  59. </script>

    分享:

    微信

    发表评论