How to Disable or Block Right Click – JavaScript

JavaScript

  1.  
  2. <script language=JavaScript>
  3. function clickIE() {
  4. if (document.all) {
  5. return false;
  6. }
  7. }
  8. function clickNS(e) {
  9. if (document.layers||(document.getElementById&&!document.all)) {
  10. if (e.which==2||e.which==3) {
  11. return false;
  12. }
  13. }
  14. }
  15. if (document.layers) {
  16. document.captureEvents(Event.MOUSEDOWN);
  17. document.onmousedown=clickNS;
  18. }
  19. else{
  20. document.onmouseup=clickNS;
  21. document.oncontextmenu=clickIE;
  22. }
  23. document.oncontextmenu=new Function("return false")
  24. </script>
  25.  
This entry was posted in JavaScript and tagged , , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Spam Protection by WP-SpamFree