Wednesday, April 14, 2010

Disabled right click options for this window - compatible with almost all browsers(I.E., Firefox, Netscape, Safari.)

If you have quality content on your webpage and want to prevent people stealing your resources, you can add this script to disable the right-mouse click. This does not assure complete safety for your resources (there is always a way to copy them), but it is better than nothing. :)

Source Code:
/*javascript functions:**/
PopUpMsg = "The right click options are disabled for this window";
isIE = document.all;
isNN = !document.all && document.getElementById;
isN4 = document.layers;

if (isIE || isNN) {
document.oncontextmenu = checkM;
}
else {
document.captureEvents(Event.MOUSEDOWN || Event.MOUSEUP);
document.onmousedown = checkV;
}

function checkM(e) {
if (isN4) {
if (e.which == 2 || e.which == 3) {
alert(PopUpMsg);
return false;
}
}
else {
alert(PopUpMsg);
return false;
}
}

No comments:

Post a Comment