Deshabilitar boton derecho del raton


/ Published in: JavaScript
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <html>
  2. <head>
  3. <title> Deshabilitar botón derecho </title>
  4. </head>
  5. <body>
  6. <script language="JavaScript1.2">
  7. var clickmessage="Right click disabled on images!"
  8. function disableclick(e) {
  9. if (document.all) {
  10. if (event.button==2||event.button==3) {
  11. if (event.srcElement.tagName=="IMG"){
  12. alert(clickmessage);
  13. return false;
  14. }
  15. }
  16. }
  17. else if (document.layers) {
  18. if (e.which == 3) {
  19. alert(clickmessage);
  20. return false;
  21. }
  22. }
  23. else if (document.getElementById){
  24. if (e.which==3&&e.target.tagName=="IMG"){
  25. alert(clickmessage)
  26. return false
  27. }
  28. }
  29. }
  30. function associateimages(){
  31. for(i=0;i<document.images.length;i++)
  32. document.images[i].onmousedown=disableclick;
  33. }
  34. if (document.all)
  35. document.onmousedown=disableclick
  36. else if (document.getElementById)
  37. document.onmouseup=disableclick
  38. else if (document.layers)
  39. associateimages()
  40. </script></body>
  41. </html>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.