how do I disable right click?

  • 1
  • Question
  • Updated 10 years ago
  • Answered
Photo of chantell giambrone

chantell giambrone

  • 2 Posts
  • 0 Reply Likes

Posted 10 years ago

  • 1
Photo of Peter

Peter

  • 2569 Posts
  • 113 Reply Likes
Hello Chantelle,

I have a link here for you that I think should do the trick.

Place this at the very bottom of your page. ie nothing added after this. This will disable right click copying of images

<!--

<script language="JavaScript1.2">

/*
Disable right click script II (on images)- By Dynamicdrive.com
For full source, Terms of service, and 100s DTHML scripts
Visit http://www.dynamicdrive.com
*/

var clickmessage="Right click disabled on images!"

function disableclick(e) {
if (document.all) {
if (event.button==2||event.button==3) {
if (event.srcElement.tagName=="IMG"){
alert(clickmessage);
return false;
}
}
}
else if (document.layers) {
if (e.which == 3) {
alert(clickmessage);
return false;
}
}
else if (document.getElementById){
if (e.which==3&&e.target.tagName=="IMG"){
alert(clickmessage)
return false
}
}
}

function associateimages(){
for(i=0;i<document.images.length;i++)
document.images[i].onmousedown=disableclick;
}

if (document.all)
document.onmousedown=disableclick
else if (document.getElementById)
document.onmouseup=disableclick
else if (document.layers)
associateimages()
</script>

-->
(disregard the leading <!-- and the trailing -->. They're put here to prevent interpretation of the code by the forum software.

May I just add that this may also have some unpredictable effects on the functioning of your pages. It's a well known phenomena. As far as preventing copying of images it doesn't appear to be very effective for the experienced mischief. Many commentators would recommend alternative strategies including Creative Commons licensing and other methods.

I wish you luck and please come back if there is anything else that we may help you with.
Photo of jeremy

jeremy, Employee

  • 1349 Posts
  • 90 Reply Likes
Hi there Chantell,

We have a detailed thread here: http://getsatisfaction.com/yola/topic... that will give you more information on the topic.

If we can be of any more assistance, please let us know.
Photo of chantell giambrone

chantell giambrone

  • 2 Posts
  • 0 Reply Likes
it's telling me: oop! an error has occured with your pasted javascript code, please check oyur code
Photo of Peter

Peter

  • 2569 Posts
  • 113 Reply Likes
Hi chantell,

This sometimes happens with java code, What you can do is repeat the paste and hit OK. It will most likely accept it the next time around.
Photo of Connor McCarra

Connor McCarra, Champion

  • 944 Posts
  • 47 Reply Likes
Hi Chantell,

Codes are just going to stop people from using right click, It won't stop your images from being copied because if someone wanted them they could just look at the page source and get the URL of the image. The best way to protect your images is to use a watermark.

Connor
Photo of Peter

Peter

  • 2569 Posts
  • 113 Reply Likes
True Connor but even the watermark is quite easy to overcome these days. there are just so many tipsters out there saying this is not for illegal use but if you have a need to recover a watermarked image this is how you do it.....!
Photo of Peter

Peter

  • 2569 Posts
  • 113 Reply Likes
Here's a few references on the subject of preventing theft of online images.

http://albertaphotography.wordpress.c...
http://forums.cnet.com/5208-10149_102...
http://www.enterpriseitplanet.com/sec...

I think it's a fairly balanced look at the issue and realistic ways of protecting and defending your property.

If anyone has experience with protecting their art online I think it would be a very helpful and informative topic to follow.