PDA

View Full Version : Disable right click



mergino
01-20-2006, 03:31 PM
I have a webpage with photo thumbnails. The following script disables right click on the thumbnails but not on the actual photo when it is enlarged (by clicking) from the thumbnail. It is the actual photo that I would like to protect. Any ideas on how to disable right click on the photo that pops up in another window?

I'm using Yahoo SiteBuilder.

<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="Copyrights do not allow this function."

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>

jscheuer1
01-20-2006, 04:01 PM
Put the disable script on the page that the photo that you want to use it with is on. If the photo isn't on a page, you will have to make a page for it, generate one at the time it is displayed, or use an alternate display method for it, where the disabling script can apply. Just for your information, these disabling scripts do nothing to protect your image from being copied. If that is all you want it for, forget about it.