Tuesday, March 3, 2009

How to disable right mouse click by using JavaScript

There are several ways to disable right mouse click but I would like to share the simplest way here with you. There is no foolproof method of stopping people from saving your images and content, but if you make it a little more difficult then you will eliminate a good proportion of visitors to your site from stealing your images.

Copy and paste the following code between the <head> </head> tags of your webpage and you are done:

<script language=JavaScript>
<!--
var message="right click disable">
function click(z) {
if (document.all) {
if (event.button == 2) {
alert(message);
return false;
}
}
if (document.layers) {
if (z.which == 3) {
alert(message);
return false;
}
}
}
if (document.layers) {
document.captureEvents(Event.MOUSEDOWN);
}
document.onmousedown=click;
// -->
</script>


Cheers!!!

Related Posts :





0 comments :

Post a Comment

 

Copyright © 2009 - tutorialfeed.org