SHARE
TWEET

Untitled

a guest Jul 22nd, 2019 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. **禁止某些键盘事件**
  2. ```language
  3.     document.addEventListener('keydown', function(event){
  4.         return !(
  5.             112 == event.keyCode || //F1
  6.             123 == event.keyCode || //F12
  7.             event.ctrlKey && 82 == event.keyCode || //ctrl + R
  8.             event.ctrlKey && 78 == event.keyCode || //ctrl + N
  9.             event.shiftKey && 121 == event.keyCode || //shift + F10
  10.             event.altKey && 115 == event.keyCode || //alt + F4
  11.             "A" == event.srcElement.tagName && event.shiftKey //shift + 点击a标签
  12.         ) || (event.returnValue = false)
  13.     });
  14. ```
  15.  
  16. **禁止右键、选择、复制**
  17. ```language
  18.     ['contextmenu', 'selectstart', 'copy'].forEach(function(ev){
  19.         document.addEventListener(ev, function(event){
  20.             return event.returnValue = false
  21.         })
  22.     });
  23. ```
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top