Solved

Using jQuery to prevent user's copying picture to clipboard

Posted on 2011-02-21
7
832 Views
Last Modified: 2012-06-21
I need to prevent user's from copying pictures to the clipboard AND disable the "Save picture as..." context menu option, when the user right clicks on the image.

Can this be done with jQuery? I need to prevent users from capturing the image either by clipboard, or selecting "Copy image" or  "Save picture as..." from the context menu, and any other way I am forgetting to grab an image from a browser page.


Thanks,
newbieweb
0
Comment
Question by:newbieweb
  • 3
  • 2
  • 2
7 Comments
 
LVL 27

Assisted Solution

by:Lukasz Chmielewski
Lukasz Chmielewski earned 150 total points
ID: 34947197
I'm afraid it is not possible. How about PrntScreen pressing ? Taking a photo of a web page ?
Not so long ago, there was a question like that on EE. The best solution as a conclusion was to add a watermark to an image.
0
 
LVL 27

Expert Comment

by:Lukasz Chmielewski
ID: 34947204
Read this if that does not convince you
http://www.graphicsacademy.com/howto_preventcopy.php
0
 
LVL 14

Assisted Solution

by:Zac Harris
Zac Harris earned 350 total points
ID: 34947234
You can try using this code to disable the right-click functionality. Unfortunately disabling the right-click functionality on a website will also prevent users from using the copy and paste functions in text boxes. I would suggest using watermarking rather than disabling right-clicking mainly due to the fact that there are so many ways to circumvent this restriction.
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>disabling right click with jQuery</title>
    <script language="javascript" type="text/javascript"
      src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
    </script>
    <script type="text/javascript" language="javascript">
        $(function() {
            $(this).bind("contextmenu", function(e) {
                e.preventDefault();
            });
        }); 
    </script>
</head>
<body>
    INSERT BODY TEXT HERE
</body>
</html>

Open in new window

0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:newbieweb
ID: 34948384
So it seems like I could disable the right click functionality. Can't I define a different context menu that the user sees based on whether they right-click on an image versus a text box?

As far as pressing PrntScreen, that's a Windows function. So I must believe that it's something that could also be disabled using my own keyboard filter which swallows the event before passing it onto Windows.

Taking a photo is clearly one way to beat this but it's not very practical.

Watermarking is interesting...
0
 

Author Comment

by:newbieweb
ID: 34948411
Can't I define a different context menu that the user sees based on whether they right-click on an image versus a text box?  Or what about a different context menu in general?

0
 
LVL 14

Accepted Solution

by:
Zac Harris earned 350 total points
ID: 34948456
Since what you are trying to do is for a website you cannot alter the context menu of the visitors to your site.

I have included a link (below) to a useful tutorial I have used before to circumvent people from stealing photos. No method is fool-proof but the steps in the tutorial at least help you make it harder for someone to take your images.

http://www.cambridgeincolour.com/tutorials/protect-online-photos.htm
0
 

Author Closing Comment

by:newbieweb
ID: 34948520
Thanks!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

680 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question