Monday, 7 May 2012

Safeguard Your Image/Graphic

Sometimes their might come a time when we work very hard for preparing a single image or graphic. We want to show it to others but they simply copy and give their name and we are left helpless. This has happened to me also sometimes and may be you have faced it too. We simply search in Google but many of them provides security to your graphic but with very hard coding.
And if we ask with webmasters they reply with JavaScript. So, isn't their is a way? Yes their is. When i thought for several times i ultimately came to know this trick. Its not any hard code like others but it simply disables right click in your image. Then let's begin.
1. Your Image URL Sample:

<img src="http://yoursite.com/image.png" />
2. Add this code just after your image url:

oncontextmenu="return false;"
3. After adding your code should look like this:

<img src="http://yoursite.com/image.png" oncontextmenu="return false;" />
So what the code does is simply disable right click on your image where you have included this code. To understand better here is a live demo:

No comments:

Post a Comment