Saturday, April 11, 2009

Write an Image in Iframe(Currently IE only)

This is something different I came across, some months back.
We can actually write an Image file in Iframe,this file is visible, but user can't save the file.
This is very simple trick which we can actually use to avoid image copying.
e.g. Though communities like orkut prohibited right click on an image, we can simple drag the image in address bar and can save it. This is something which we can't avoid in normal scenario, but there is one way to deal with this, using ASP.NET and it's handler concept.
I have already talked about ashx file in one of my previous article on image handling

Lets go step by step

Step 1
Create one file names Image.ashx
copy paste following code

save file, check the assignment of string names "img" in above code.

step 2

In aspx file generally add an Iframe as below

step 3
Add followin javascript function

step 4
On body 'onload' event call above function as

Run your code, make sure that you assign correct Image in Image.ashx file.
Now if you run your code you can get an image in iframe which can't be saved Digg Technorati Delicious StumbleUpon Reddit BlinkList Furl Mixx Facebook Google Bookmark Yahoo
ma.gnolia squidoo newsvine live netscape tailrank mister-wong blogmarks slashdot spurl

No comments:

Post a Comment

blogger templates 3 columns | Make Money Online