Click to See Complete Forum and Search --> : How 2 deactivate right click


Caliban
10-10-2003, 08:04 PM
Hi y'all JS gurues!
Is it possible ...? to deactivate the right-click event on a link?

that's all.

Kind regards

jrbp
10-10-2003, 08:25 PM
This is how you can get right click disabled for th whole page:<script language=JavaScript>
<!--

//Disable right mouse click Script
//By Maximus (maximus@nsimail.com) w/ mods by DynamicDrive
//For full source code, visit http://www.dynamicdrive.com

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>


from: http://www.dynamicdrive.com/dynamicindex9/noright.htm

Caliban
10-10-2003, 08:39 PM
Thanx,
it works fine as is.

I only had to translate the message text (from english to spanish) and voilá :D

by the way, this is the first post about this issue ... i suppose :rolleyes:

kind regards.