Disable right click help needed

I am wanting to know how can I make this script, have the right click menu be disabled for all other browsers - Firefox, Opera, etc?


function right(e) {
if (navigator.appName == 'Netscape' && 
(e.which == 3 || e.which == 2))
return false;
else if (navigator.appName == 'Microsoft Internet Explorer' && 
(event.button == 2 || event.button == 3)) {
alert("Sorry, these images are copyright protected.");
return false;
}
return true;
}

document.onmousedown=right;
document.onmouseup=right;
if (document.layers) window.captureEvents(Event.MOUSEDOWN);
if (document.layers) window.captureEvents(Event.MOUSEUP);
window.onmousedown=right;
window.onmouseup=right;

Does anyone have any other suggestions to prevent website visitors, from saving photos to their computer?

Thanks in advance.

Instead of checking for the navigator.appName, you would check for e.which or event.button (which is the better way of doing this anyway), but as Spike says, this is quite anti-social and in fact, when this is done, I actually enjoy circumventing the block to get what I want.

At the end of the day, if you don’t want people stealing your images, watermark them or make them small enough that they can be seen but look bad if they are blown up.

This is one of the many should I/Shouldn’t I things on the internet. Like music that plays when you arrive on the site - some love it, some hate it.

My own personal advice is not to waste your time trying to stop the right click event - if I want your images then I can get them. Its only personal preference but I really hate it when someone tries to control something that is mine, ie my mouse. I use the right click for more than saving links and images and to have it interefered with is just plain annoying!

Think of other ways to stop them images being used - watermarks perhaps?

Opera turns off the ability to disable right click by default so you would need your visitors to deliberately change their settings in order to allow it to be disabled.

Even for those browsers that don’t provide a simple way within the browser to turn off disabble right click scripts it is trivial to install a bookmarklet that can be run against any web page to turn it back on again (without having to turn off JavaScript completely)

Disabling right click won’t prevent them, there are other ways they can copy the image and there’s no JavaScript solution to prevent all of them… they could drag and drop the image from the browser window to their desktop, they could go through the source code to get the image URL and download it directly, they could use a Firefox plug-in to grab the file, they could go to the browser cache and simply copy the downloaded image, they could use their print screen button (outside of the browser) and take an exact snapshot of the file, they could disable scripting and then right click and save the image, the list is endless. If it’s on the web it can’t be bolted down. If you don’t want it copied, don’t upload it. The only people right click cripple scripts affect are legitimate users. :slight_smile: