JavaScript - Disable Right Click


SUBMITTED BY: KrisPerry

DATE: April 18, 2017, 9:21 a.m.

FORMAT: JavaScript

SIZE: 781 Bytes

HITS: 383

  1. <!-- To disable right click -->
  2. <script language=JavaScript>
  3. var message="This function has been Disabled!";
  4. ///////////////////////////////////
  5. function clickIE4(){
  6. if (event.button==2){
  7. alert(message);
  8. return false;
  9. }
  10. }
  11. function clickNS4(e){
  12. if (document.layers||document.getElementById&&!document.all){
  13. if (e.which==2||e.which==3){
  14. alert(message);
  15. return false;
  16. }
  17. }
  18. }
  19. if (document.layers){
  20. document.captureEvents(Event.MOUSEDOWN);
  21. document.onmousedown=clickNS4;
  22. }
  23. else if (document.all&&!document.getElementById){
  24. document.onmousedown=clickIE4;
  25. }
  26. document.oncontextmenu=new Function("alert(message);return false")
  27. // -->
  28. </script>

comments powered by Disqus