disable right mouse
If you want to disable the right mouse click, to stop someone grabbing your images or looking at your html/javascript code just use this simple script below:
JavaScript Code to Disable Right Mouse Click
<SCRIPT LANGUAGE="JavaScript"> function noRightClick(buttonClicked) { if (navigator.appName == 'Netscape' && (buttonClicked.which == 2 || buttonClicked.which == 3)) return false; else if (navigator.appName == 'Microsoft Internet Explorer' && (event.button == 3 || event.button == 2)) { alert("Your Message Goes Here"); return false; } return true; } document.onmousedown=noRightClick; document.onmouseup=noRightClick; if (document.layers) window.captureEvents(Event.MOUSEDOWN); if (document.layers) window.captureEvents(Event.MOUSEUP); window.onmousedown=noRightClick; window.onmouseup=noRightClick; </script>
Please note
The message displayed when someone clicks their right mouse button is contained in the line:
alert("Your Message Goes Here");
If the message you enter also has quotes in it they need to be escaped with a backslash
e.g. alert("Your \"Message\" Goes Here");
If you use quotes in your message and don't escape them the script will fail!
You can download a simple right click code generator script utility from this page here.
To see an example of the script in action click here just right click anywhere in the page.
|