I have been asked by a client if it is possible to have an image appear when a user tries a screengrab on images on his website.
Can this be done?

There are javadcript functions to intercept the screen right click function:

http://javascript.internet.com/page-details/disable-images-click.html

Any savvy user can easily circumvent this, but it does force the user to use a work around.

I have seen another trick where the background for an element is set to the image you want and then a transparent image is placed over it. When the user right-clicks to download the image all they get the transparent image:

<table>
  <tr>
    <td style="background-image: url ('images/image2view.jpg'); 
        background-repeat: no-repeat; background-position: center;">
      <img src="transparent.jpg" />
    </td>
  </tr>
</table>

There are still ways around this, just by viewing the source, but you are making it just a little more difficult. There are programs that obfuscate your HTML to make it harder to read and figure out.

If you look at most photo sites they use a watermark to protect their images rather than trying to protect the site via code and such.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.