We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you a podcast all about Citrix Workspace, moving to the cloud, and analytics & intelligence. Episode 2 coming soon!Listen Now

x

right click protect images

Medium Priority
324 Views
Last Modified: 2012-05-06
Hello Everyone:
What is the easiest way to prohibit right click menu options for the images on our site.  Basically, we have used the following code for the the thumbnail images; however, how do we protect the larger image linked to the thumbnail? Thank you very much.

<SCRIPT LANGUAGE="JavaScript1.1">

<!-- Begin
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, you do not have permission to right click.");
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;
//  End -->
</script>
</HEAD>
Comment
Watch Question

The idea behind this kind of protection is to prevent the user from easily figuring out what the URL of the image is. Once they know the URL, there's nothing you can do to stop them. That said, it's not possible to do that. Any savvy user can look at the page source, or examine the page in Firebug, identify the image on the server, and then download it directly. Disabling right click won't stop those who know what they're doing, and will annoy everyone else.

That said, the way you prevent your larger images from being downloaded, is you do not ever link *directly* to an image from a thumbnail. Have your thumbnails to a separate "large version" page which displays the large image, and also protects from right clicks just like what you've already done.

The only bulletproof way I can see of doing this is to have some kind of server side code deliver the images on a per-request basis, each page generating a "ticket" which gives it one time access to the images. You never link to a real image, instead you link to the server script that delivers the image. We can explore that option if you tell me what kind of server side languages you have available. PHP? ASP?

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Commented:
Easiest way is to open your images in a custom-size pop-up window.
Most of the normal internet users can't figure out the image name in Pop-up widow JavaScript.

Then apply no-right-click script, and turn off menu-bar, toolbar of that pop-up window, then it would help, because many users don't know how to view page source of a pop-up window.

Another optional addition to this, is applying a Window-close script/function on right click, so if someone tries to right-click on that pop-up, it will close. So next time he would just view your images and won't try to right-click on them...

You cannot make it 100% safe, but at least it will prevent many...

In fact, you can never make anything on a webpage 100% copy free, but can try it for general audience.

:-D
CERTIFIED EXPERT
Commented:
Another fun way is with CSS. Save a tiny transparent TIFF or PNG and stretch it across a DIV that sits above your image. Then let them right click and download the transparent TIFF to their hearts content.
For added fun, make a nearly transparent message such as "Stop Stealing Images" that will not be visable over the image, but will show up when downloaded and viewed against a white background".
Frosty makes a very good point about not being able to protect your image. The subject was nearly run into the ground here http://www.experts-exchange.com/Web_Development/Images/Q_21912288.html

Author

Commented:
Thank you for all of the responses and I apologize for not responding myself sooner.  I am interested in the custom-size pop-up window and stopping the right click behavior by applying a no-right-click script, and turning off menu-bars/toolbars of that pop-up window - would you happen to having any coding available for this?  Also, does anyone have any feedback on protware or web album generator?  
Thanks again.
Commented:
To create pop-up window with custom size and properties, use this link:
http://www.dynamicdrive.com/dynamicindex8/popwin.htm

To prevent right-click, use the script:
http://www.dynamicdrive.com/dynamicindex9/noright3.htm

:-)
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.