right click JavaScript

rolandr

New Member
Messages
72
Reaction score
0
Points
0
I found a useful JavaScript for website when you right click, an alert message pops up. This prevent the viewer from copying images on your website. Of course there's ways around it.

I know many of you this script isn't anything new but this script works in MS Internet Explorer but not in my Mozilla Fire Fox.

Here's the script. I kept the source from where I got it intact because its good practice to state your source.

/*
Thank you for choosing Java-scripts.net
as your javascript resource site. Below
is the free javascript code that you requested
along with installation instructions. We
look forward to seeing you again at
http://www.java-scripts.net
===============================

Script Details
Title: No Right Click
Description: Disable right clicking on your site to prevent people from stealing your images and code!
===============================

Copy the following code into your HEAD tags.
===============================


No rightclick script v.2.5
(c) 1998 barts1000
barts1000@aol.com
Don't delete this header!
*/

var message="\nImages are property of RR\nImages and Text protected!\nALL RIGHTS RESERVED";

// Don't edit below!

function click(e) {
if (document.all) {
if (event.button == 2) {
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;


Does anyone know the JavaScript that works both in IE and FireFox?
 

ah-blabla

New Member
Messages
375
Reaction score
7
Points
0
I recommend you DON'T use such scripts at all -- they are simply irritating, and switching javascript off removes all protection (By default I don't run JS on any sites, so this "protection" wouldn't work for me...). If it is images you are protecting, then any user can get the image files directly from their cache folder if they want, even if JS is active.

If you insist on using such a script (and want to irritate users) then here is a script claiming to "support" FF as well as IE.
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
It's fairly easy to have such scripts target only images by registering the handler on images (accessible via document.images) rather than the entire document. This won't provide any more protection, but will greatly reduce annoyance. Another option is to position a transparent image on top of each image you wish to protect. Yet another option is to watermark the image.

To prevent caching in IE, you can send "Cache-control: no-cache", "Expires: -1" and "Pragma: no-cache" headers, though even this won't be enough to prevent someone from d/ling an image.

The most reliable solution is not to put hi-res pictures online.
 
Top