Gator_Bks

Disable Copy Paste

Aug 19th, 2024 (edited)
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JavaScript 1.20 KB | Source Code | 0 0
  1. <!-- Disable Copy Paste -->
  2.  
  3. <script>
  4.     function check(e){
  5.         alert(e.keyCode);
  6.     }
  7.     document.onkeydown = function(e) {
  8.         if (e.ctrlKey && (e.keyCode === 67 || e.keyCode === 86 || e.keyCode === 85 || e.keyCode === 117)) {
  9.         //Alt+c, Alt+v will also be disabled sadly.
  10.         alert("Sorry you can't copy and paste in here");
  11.         }
  12.         return false;
  13.     };
  14. </script>
  15.  
  16. <script type='text/javascript'>
  17.     var isCtrl = false;
  18.     document.onkeyup=function(e){
  19.         if(e.which == 17)
  20.         isCtrl=false;
  21.     }
  22.     document.onkeydown=function(e){
  23.         if(e.which == 17)
  24.         isCtrl=true;
  25.         if((e.which == 85) || (e.which == 67) &amp;&amp; isCtrl == true){
  26.             // alert(&#8216;Keyboard shortcuts are cool!&#8217;);
  27.             return false;
  28.         }
  29.     }
  30.     var isNS = (navigator.appName == "Netscape") ? 1 : 0;
  31.     if(navigator.appName == "Netscape") document.captureEvents(Event.MOUSEDOWN||Event.MOUSEUP);
  32.     function mischandler(){
  33.         return false;
  34.     }
  35.     function mousehandler(e){
  36.         var myevent = (isNS) ? e : event;
  37.         var eventbutton = (isNS) ? myevent.which : myevent.button;
  38.         if((eventbutton==2)||(eventbutton==3)) return false;
  39.     }
  40.     document.oncontextmenu = mischandler;
  41.     document.onmousedown = mousehandler;
  42.     document.onmouseup = mousehandler;
  43. </script>
Tags: js
Advertisement
Add Comment
Please, Sign In to add comment