View Full Version : Disable right mouse click script II (on images)

07-25-2006, 05:43 PM
1) Script Title:
Disable right mouse click script II (on images)

2) Script URL (on DD):
<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"){
return false;
else if (document.layers) {
if (e.which == 3) {
return false;
else if (document.getElementById){
if (e.which==3&&e.target.tagName=="IMG"){
return false

function associateimages(){

if (document.all)
else if (document.getElementById)
else if (document.layers)

3) Describe problem:
It doesn't work for me. I'm not sure what I am doing wrong. Please help.

07-25-2006, 05:57 PM
I'm not sure what I am doing wrong. Please help.

That's easy, using the script. That's what you are doing wrong. Seriously, this type of script often doesn't work and always adds weight to your page. Even when it does work, the images can be easily copied in several alternative ways. Copyright is the only foolproof method of protecting your images and the good news is that - original images (and all original material) is copyright just by virtue of being published on the web.

07-25-2006, 07:48 PM
Thank you, John. I am aware that they can still copy. My goal is to make it hard for someone to inadvertently copy my images. A lot of people don't realize that the images are copyrighted because of the "toolbar" and "right click" options make it look like it's okay to copy.
I was able to disable the toolbar, until I started nesting frames. I do know there are a lot of websites out there that successfully disabled the "right click" option and give an alert notice. I'd really like to try to make it work.

07-25-2006, 08:22 PM
<script type="text/javascript">
window.onload = function() {
for(var i = 0, e = document.images; i < e.length; ++i)
e[i].onmousedown = function(e) {
var ev = e || window.event;
if(!ev) return;
if((ev.srcElement || ev.target).tagName.toLowerCase() == "img")
if (ev.button &&
(ev.button == 2 || ev.button == 3)
) {
return false;
} else if(ev.which && ev.which == 3) {
return false;
return true;
</script>However, there are still better ways to advertise your copyright. If people don't notice it, it evidently doesn't stand out enough. One good trick is to set the title attribute of the images to something like "Warning: this image is copyrighted. See copyright notice at bottom of page." That way, if somebody using IE hovers their mouse over it to get the image toolbar, they'll see that message as well.

07-25-2006, 08:36 PM
Please forgive my ignorance, but I just starting teaching myself GoLive so I can build my own website. Can you please elaborate on how to "title" something?

07-25-2006, 08:55 PM
<img src="image.png" title="Warning: this image is copyrighted. See copyright notice at bottom of page.">