Saturday, 27 October 2012

How to disable Right Clicks in your Website or Blog



Sometimes you may need to disable right clicks on your pages, may be to disable copying of contents or to disable other such events.
Well to do this a need to install a script. For Blogger, you have to install a "HTML/Java Script" widget and copy the code in that.

You can add your custom message by replacing the text in RED in the script  ("Function Disabled!").


SCRIPT

<script language=JavaScript>
<!--

//Disable right mouse click Script

var message="Function Disabled!";

///////////////////////////////////
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>