cest-lavie

Bloqueio do botão direito do mouse

May 12th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1.  
  2. <script type="text/javascript">
  3.  
  4. //desabilita menu de opcoes ao clicar no botao direito
  5.  
  6. function desabilitaMenu(e)
  7.  
  8. {
  9.  
  10. if (window.Event)
  11.  
  12. {
  13.  
  14. if (e.which == 2 || e.which == 3)
  15.  
  16. return false;
  17.  
  18. }
  19.  
  20. else
  21.  
  22. {
  23.  
  24. event.cancelBubble = true
  25.  
  26. event.returnValue = false;
  27.  
  28. return false;
  29.  
  30. }
  31.  
  32. }
  33.  
  34. //desabilita botao direito
  35.  
  36. function desabilitaBotaoDireito(e)
  37.  
  38. {
  39.  
  40. if (window.Event)
  41.  
  42. {
  43.  
  44. if (e.which == 2 || e.which == 3)
  45.  
  46. return false;
  47.  
  48. }
  49.  
  50. else
  51.  
  52. if (event.button == 2 || event.button == 3)
  53.  
  54. {
  55.  
  56. event.cancelBubble = true
  57.  
  58. event.returnValue = false;
  59.  
  60. return false;
  61.  
  62. }
  63.  
  64. }
  65.  
  66. //desabilita botao direito do mouse
  67.  
  68. if ( window.Event )
  69.  
  70. document.captureEvents(Event.MOUSEUP);
  71.  
  72. if ( document.layers )
  73.  
  74. document.captureEvents(Event.MOUSEDOWN);
  75.  
  76. document.oncontextmenu = desabilitaMenu;
  77.  
  78. document.onmousedown = desabilitaBotaoDireito;
  79.  
  80. document.onmouseup = desabilitaBotaoDireito;
  81.  
  82. </script>
Add Comment
Please, Sign In to add comment