Disable right mouse click

Post new topic   Reply to topic

View previous topic View next topic Go down

Disable right mouse click

Post by Null-11 on Sun May 04, 2008 9:54 pm

This code disables right click on the page that contains the code. This works in FireFox 1+ and Internet Explorer 5+.

To add this to you site, just paste the following code to the <BODY> section of your web page:
Code:
<script language=JavaScript>
<!--

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>


Almost forgot, you can change the var message="Function Disabled!"; text to make the popup warning message say something else. For example, you may want it to say Right click is disabled on this website. The code for that would be: var message="Right click is disabled on this website.";
Hope someone finds this useful. Very Happy

Stay connected to us with the NEW Add My Forum Community Toolbar!

Null-11
Admin
Admin

Posts : 793
Joined : 24 Dec 2007

Back to top Go down

View previous topic View next topic Back to top


Permissions of this forum:

You cannot reply to topics in this forum