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 !!!! :)
All Replies (4)
There is a simple setting in Firefox to override websites doing exactly what you are trying to do, so don't bother.
Tools > Options > Content : JavaScript > Advanced > Allow Scripts to: "Disable or replace context menus"
You can also always save images via Tools > Page Info > Media
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.
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.