JavaScript – Images – No Right Click
This script disallows the use of right clicking so your images have a bit more protection from being stolen from your page.
<html> <head> <script LANGUAGE="JavaScript"> <!-- Begin function protect(e) { alert("Sorry, you don't have permission to right-click."); return false; } function trap() { if(document.images) for(i=0;i<document.images.length;i++) document.images[i].onmousedown = protect; } // End --> </script> </head> <body OnLoad="trap()"> <div align="center"> <!--DESCRIPTION HERE--> This script disallows the use of right clicking so your images have a bit more protection from being stolen from your page. <br><br> Try right clicking on this image! <br> <img src="http://www.lucedigitale.com/principale/images/logo.png"> </div> </body> </html>
Notice the command to trap the mouse click in the whole body document:
<body OnLoad="trap()">
The function finds all the images in the body:
function trap() { if(document.images) for(i=0;i<document.images.length;i++) document.images[i].onmousedown = protect; }