Pages

Sunday, October 31, 2010

No Right Click

One of the common ways to prevent people from trying to view your source, or from saving your images, is to disable the right mouse button with javascript. Instead of a menu popping up when they right-click on your page, they get an alert saying whatever you want it to say. Try right-clicking anywhere on this page, and you'll see what I mean.

It is far from foolproof. The determined theif can still click View on the toolbar and get your source from there, and your images will still be downloaded to their local cache. Also, it prevents innocent visitors from using the right mouse button to open links in a new window, or adding a link to their favorites, which can be annoying. So it's up to you whether you want to bother using it or not.

Click here to select the code in the window below, then use Ctrl+C to copy it to your clipboard. Paste it between the <head> and </head> tags of your HTML document. 
___________________________________
<SCRIPT LANGUAGE="javascript"><!--
function rightclick() {
if (event.button==2) {
alert('This function is disabled.')
}
}
document.onmousedown=rightclick
// --></SCRIPT>                                           
Note: This code only works for Internet Explorer.

0 Comments:

Post a Comment