Helpfull Code Tips

Nothxkbi

Banned
Joined
Mar 19, 2010
Messages
4,529
Reaction score
3
Location
Amanzimtoti - KZN
Alright I'm often coming across things we could all use so just gonna dump them here when I find them with a small description of what it does. :)

Came across this today, its pretty self explanatory, basically protects all the images on your site from being copied.

Code:
</script>
<script language="JavaScript" src="scripts/overlib.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript"> 
<!--
function protect() 
{	if (event.button==2 || event.button==3)
		{	alert("All images and content of this website are copyright or licensed to\nJoe Soap and Company.");
			return false;
		}
	else
		{	return true;
		}
}
 
function trap() {	
	
	
	if (document.images) {
		for (i=0;i<document.images.length;i++){	
			document.images[i].onmousedown = protect;
		}
	}	
}
 
//-->
</script>
 
Disabling right click via Javascript is the worst copy protection ever.

Not to mention it's extremely annoying.
 
if you are really worried about your images being.. "stolen".. try this..

Code:
<table border="0" cellpadding="0" cellspacing="0"
   <tr>
     <td background="realimage.jpg" width="300" height="400">
          <img border="0" src="fakeimg.gif" width="300"height="400">
     </td>
   </tr>
</table>

this way if they rightclick on it.. it will save the "fake" image and not the real one.
 
if you are really worried about your images being.. "stolen".. try this..

Code:
<table border="0" cellpadding="0" cellspacing="0"
   <tr>
     <td background="realimage.jpg" width="300" height="400">
          <img border="0" src="fakeimg.gif" width="300"height="400">
     </td>
   </tr>
</table>

this way if they rightclick on it.. it will save the "fake" image and not the real one.

Will try this one thanks!

The right click is very annoying I must agree. A simple screenshot overcomes all of this but not everyone has the savvy to figure that out :D
 
This isn't fool proof though. Someone can simply turn javascript off.
 
When you save the web page on local machine, it also saves the associated files (.css, .js, jpg, etc)
 
Top
Sign up to the MyBroadband newsletter
X