查看: 4467|回复: 0

禁止查看元素 禁F12 禁鼠标右键 禁复制

[复制链接]

51

主题

59

帖子

400

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
400
发表于 2018-9-21 21:48:00 | 显示全部楼层 |阅读模式
禁止查看元素 禁F12 禁鼠标右键 禁复制

  1. /*禁止F12*/
  2. document.onkeydown = function(){

  3.     if(window.event && window.event.keyCode == 123) {
  4.         event.keyCode=0;
  5.         event.returnValue=false;
  6.     }
  7.     if(window.event && window.event.keyCode == 13) {
  8.         window.event.keyCode = 505;
  9.         alert(进入);
  10.     }
  11.     if(window.event && window.event.keyCode == 8) {
  12.         alert(str+"\n请使用Del键进行字符的删除操作!");
  13.         window.event.returnValue=false;
  14.         alert(空格);
  15.     }
  16.     if(window.event && window.event.keyCode == 64){
  17.         window.event.returnValue=false;
  18.         alert(哈哈)
  19.     }

  20. };
复制代码
.................................................................................................
  1. //禁止选中
  2. document.onselectstart = function (event){
  3.     if(window.event){
  4.         event = window.event;
  5.     }try{
  6.         var the = event.srcElement;
  7.         if (!((the.tagName == "INPUT" && the.type.toLowerCase() == "text") || the.tagName == "TEXTAREA")){
  8.             return false;
  9.         }
  10.         return true;
  11.     } catch (e) {
  12.         return false;
  13.     }
  14. };
  15. /*禁止复制*/
  16. document.oncontextmenu = function (event){
  17.     if(window.event){
  18.         event = window.event;
  19.     }try{
  20.         var the = event.srcElement;
  21.         if (!((the.tagName == "INPUT" && the.type.toLowerCase() == "text") || the.tagName == "TEXTAREA")){
  22.             return false;
  23.         }
  24.         return true;
  25.     }catch (e){
  26.         return false;
  27.     }
  28. };
复制代码
......................................................................
  1. /*禁止审查元素*/
  2. jQuery(document).keydown(function(event) {
  3.     var src = (event.srcElement || event.target);
  4.     if (src != null && src.nodeType == 1) {
  5.         var nodeName = src.nodeName.toLowerCase();
  6.         if (nodeName == "input" || nodeName == "textarea") {
  7.             return true;
  8.         }
  9.     }
  10.     if (event.keyCode == 67 && event.ctrlKey == true) {
  11.         return false;
  12.     }
  13.     return true;
  14. });
  15. jQuery(document).keyup(function(event) {
  16.     var src = (event.srcElement || event.target);
  17.     if (src != null && src.nodeType == 1) {
  18.         var nodeName = src.nodeName.toLowerCase();
  19.         if (nodeName == "input" || nodeName == "textarea") {
  20.             return true;
  21.         }
  22.     }
  23. })
复制代码
..............................................................
  1. 顺道给粘贴一下 keycode 数字对应的按键
  2. keycode 8 = BackSpace BackSpace
  3. keycode 9 = Tab Tab
  4. keycode 12 = Clear
  5. keycode 13 = Enter
  6. keycode 16 = Shift_L
  7. keycode 17 = Control_L
  8. keycode 18 = Alt_L
  9. keycode 19 = Pause
  10. keycode 20 = Caps_Lock
  11. keycode 27 = Escape Escape
  12. keycode 32 = space space
  13. keycode 33 = Prior
  14. keycode 34 = Next
  15. keycode 35 = End
  16. keycode 36 = Home
  17. keycode 37 = Left
  18. keycode 38 = Up
  19. keycode 39 = Right
  20. keycode 40 = Down
  21. keycode 41 = Select
  22. keycode 42 = Print
  23. keycode 43 = Execute
  24. keycode 45 = Insert
  25. keycode 46 = Delete
  26. keycode 47 = Help
  27. keycode 48 = 0 equal braceright
  28. keycode 49 = 1 exclam onesuperior
  29. keycode 50 = 2 quotedbl twosuperior
  30. keycode 51 = 3 section threesuperior
  31. keycode 52 = 4 dollar
  32. keycode 53 = 5 percent
  33. keycode 54 = 6 ampersand
  34. keycode 55 = 7 slash braceleft
  35. keycode 56 = 8 parenleft bracketleft
  36. keycode 57 = 9 parenright bracketright
  37. keycode 65 = a A
  38. keycode 66 = b B
  39. keycode 67 = c C
  40. keycode 68 = d D
  41. keycode 69 = e E EuroSign
  42. keycode 70 = f F
  43. keycode 71 = g G
  44. keycode 72 = h H
  45. keycode 73 = i I
  46. keycode 74 = j J
  47. keycode 75 = k K
  48. keycode 76 = l L
  49. keycode 77 = m M mu
  50. keycode 78 = n N
  51. keycode 79 = o O
  52. keycode 80 = p P
  53. keycode 81 = q Q at
  54. keycode 82 = r R
  55. keycode 83 = s S
  56. keycode 84 = t T
  57. keycode 85 = u U
  58. keycode 86 = v V
  59. keycode 87 = w W
  60. keycode 88 = x X
  61. keycode 89 = y Y
  62. keycode 90 = z Z
  63. keycode 96 = KP_0 KP_0
  64. keycode 97 = KP_1 KP_1
  65. keycode 98 = KP_2 KP_2
  66. keycode 99 = KP_3 KP_3
  67. keycode 100 = KP_4 KP_4
  68. keycode 101 = KP_5 KP_5
  69. keycode 102 = KP_6 KP_6
  70. keycode 103 = KP_7 KP_7
  71. keycode 104 = KP_8 KP_8
  72. keycode 105 = KP_9 KP_9
  73. keycode 106 = KP_Multiply KP_Multiply
  74. keycode 107 = KP_Add KP_Add
  75. keycode 108 = KP_Separator KP_Separator
  76. keycode 109 = KP_Subtract KP_Subtract
  77. keycode 110 = KP_Decimal KP_Decimal
  78. keycode 111 = KP_Divide KP_Divide
  79. keycode 112 = F1
  80. keycode 113 = F2
  81. keycode 114 = F3
  82. keycode 115 = F4
  83. keycode 116 = F5
  84. keycode 117 = F6
  85. keycode 118 = F7
  86. keycode 119 = F8
  87. keycode 120 = F9
  88. keycode 121 = F10
  89. keycode 122 = F11
  90. keycode 123 = F12
  91. keycode 124 = F13
  92. keycode 125 = F14
  93. keycode 126 = F15
  94. keycode 127 = F16
  95. keycode 128 = F17
  96. keycode 129 = F18
  97. keycode 130 = F19
  98. keycode 131 = F20
  99. keycode 132 = F21
  100. keycode 133 = F22
  101. keycode 134 = F23
  102. keycode 135 = F24
  103. keycode 136 = Num_Lock
  104. keycode 137 = Scroll_Lock
  105. keycode 187 = acute grave
  106. keycode 188 = comma semicolon
  107. keycode 189 = minus underscore
  108. keycode 190 = period colon
  109. keycode 192 = numbersign apostrophe
  110. keycode 210 = plusminus hyphen macron
  111. keycode 211 =
  112. keycode 212 = copyright registered
  113. keycode 213 = guillemotleft guillemotright
  114. keycode 214 = masculine ordfeminine
  115. keycode 215 = ae AE
  116. keycode 216 = cent yen
  117. keycode 217 = questiondown exclamdown
  118. keycode 218 = onequarter onehalf threequarters
  119. keycode 220 = less greater bar
  120. keycode 221 = plus asterisk asciitilde
  121. keycode 227 = multiply division
  122. keycode 228 = acircumflex Acircumflex
  123. keycode 229 = ecircumflex Ecircumflex
  124. keycode 230 = icircumflex Icircumflex
  125. keycode 231 = ocircumflex Ocircumflex
  126. keycode 232 = ucircumflex Ucircumflex
  127. keycode 233 = ntilde Ntilde
  128. keycode 234 = yacute Yacute
  129. keycode 235 = oslash Ooblique
  130. keycode 236 = aring Aring
  131. keycode 237 = ccedilla Ccedilla
  132. keycode 238 = thorn THORN
  133. keycode 239 = eth ETH
  134. keycode 240 = diaeresis cedilla currency
  135. keycode 241 = agrave Agrave atilde Atilde
  136. keycode 242 = egrave Egrave
  137. keycode 243 = igrave Igrave
  138. keycode 244 = ograve Ograve otilde Otilde
  139. keycode 245 = ugrave Ugrave
  140. keycode 246 = adiaeresis Adiaeresis
  141. keycode 247 = ediaeresis Ediaeresis
  142. keycode 248 = idiaeresis Idiaeresis
  143. keycode 249 = odiaeresis Odiaeresis
  144. keycode 250 = udiaeresis Udiaeresis
  145. keycode 251 = ssharp question backslash
  146. keycode 252 = asciicircum degree
  147. keycode 253 = 3 sterling
  148. keycode 254 = Mode_switch
复制代码

回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

快速回复 返回顶部 返回列表