PDA

View Full Version : What is the javascript to ban the right mouse click in the web page?


ngquochung86
03-05-2006, 08:17 AM
On some web pages that contain picture gallery, I recognize that the author banned the right mouse click to save image because of the protection of copyright for the image. I find it really interesting and I wanna discover how they did that? What scripts did they use for that?
Moreover, I turned off the Javascript function on the page but the disallowance of right mouse click still continues. Why it happens so? Is it actually script of simply HTML code?
Furthermore, I install a plugin of Maxthon browser that allows right mouse click and since then, I could click right mouse button wherever I want to. Hence, I really wonder how that plugin works? It is like the Flash catcher program which allows to save SWF flash animation meanwhile the browser doesn't have that function. I really want to discover that mystery.
I look forward to receiving your reply a lot. Thank you very much for your help.
Best wishes,
Quoc Hung

Vege
03-05-2006, 09:23 AM
There is no way you can prevent people from steling you pictures that are on the net. Best is to watermark em with seperate programs.

You can sure make it hard, but not stop it.

Geoserv
03-06-2006, 09:14 AM
You could use this script:

<script language=JavaScript>
<!--
//Disable right mouse click Script
//Edit the var message function below to your choosing. This is the message that will be displayed to the user

var message="Function disabled to protect artwork. Thank you.";

///////////////////////////////////
function clickIE4(){
if (event.button==2){
alert(message);
return false;
}
}

function clickNS4(e){
if (document.layers||document.getElementById&&!document.all){
if (e.which==2||e.which==3){
alert(message);
return false;
}
}
}

if (document.layers){
document.captureEvents(Event.MOUSEDOWN);
document.onmousedown=clickNS4;
}
else if (document.all&&!document.getElementById){
document.onmousedown=clickIE4;
}

document.oncontextmenu=new Function("alert(message);return false")

// -->
</script>


It wont prevent someone from stealing your content, but it will make it a little less easy to do so.

Geoserv.