Tap here to go to the mobile version of the site.
Your Firefox is out of date and may contain a security risk! Upgrade Firefox

Support Forum

Javascript to disable right click is not working in Firefox


I have a simple script that I use on my website to disable the use of right click to copy images etc. It works in IE but not Firefox. Here is teh script

var message="Thank you for visiting my site.\n\nCopying text and images is disabled on this page to protect Copyright. \n\nHowever if you want permission to use text or images please email me.\n\nThis Site Copyright ©2011."; function click(e) { if (document.all) { if (event.button==2||event.button==3) { alert(message); return false; } } if (document.layers) { if (e.which == 3) { alert(message); return false; } } } if (document.layers) { document.captureEvents(Event.MOUSEDOWN); } document.onmousedown=click;

I have read somewhere that the document.all and document.layers do not work. If this is the case how so I achieve this in Firefox.

I am a TOTAL NOVICE so please be nice !!!! :)

Additional System Details

Installed Plug-ins

  • Next Generation Java Plug-in 10.17.2 for Mozilla browsers
  • NPRuntime Script Plug-in Library for Java(TM) Deploy
  • Shockwave Flash 11.6 r602
  • Adobe Shockwave for Director Netscape plug-in, version 12.0
  • Adobe PDF Plug-In For Firefox and Netscape "9.5.4"
  • Google Update
  • npFFApi
  • 5.1.10411.0
  • GEPlugin
  • Office Plugin for Netscape Navigator


  • User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:19.0) Gecko/20100101 Firefox/19.0

More Information

scorpiodan 1 solutions 14 answers

There is a simple setting in Firefox to override websites doing exactly what you are trying to do, so don't bother.

  • Top 10 Contributor
  • Moderator
10756 solutions 96800 answers

Tools > Options > Content : JavaScript > Advanced > Allow Scripts to: "Disable or replace context menus"

You can also always save images via Tools > Page Info > Media

Helpful Reply

I appreciate that it can be overriden although many people don't know how to do that. It's just that I've had almost half my wesbite ripped off by someone else and I want to at least try and protect it from someone else doing the same thing.

  • Top 10 Contributor
  • Moderator
3197 solutions 24404 answers

Search for scripts which block the context menu in Firefox, and then test those scripts yourself on your website with Firefox. They are out there because I run into them almost daily and they don't obey the setting which cor-el mentioned, and I need to override them via a bookmarklet.