Search Support

Avoid support scams. We will never ask you to call or text a phone number or share personal information. Please report suspicious activity using the “Report Abuse” option.

Learn More

Javascript to disable right click is not working in Firefox

more options

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 !!!! :)

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 !!!! :)

All Replies (4)

more options

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

more options

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

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

more options

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.

more options

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.