Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Disable the printscreen option using javascript

Posted on 2009-04-15
4
Medium Priority
?
189 Views
Last Modified: 2014-10-18
The Following code its disable drag and click, but when u clear the clipboard only IE only its works,
but IE8 its ask for the user prompt. But other borwsers won't works. Pls provide me the solution
<script>
var message="";
function clickIE() {if (document.all) {(message);return false;}}
function clickNS(e) 
{
if (document.layers||(document.getElementById&&!document.all)) {
if (e.which==2||e.which==3) {(message);return false;}}}
if (document.layers)
{document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}
</script>

Open in new window

0
Comment
Question by:karthik_surya16
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 1

Expert Comment

by:parul11183
ID: 24148719
Try CSS:
Add this to the head of the page:

<link rel="stylesheet" type="text/css" href="printstyle.css" media="print">

And in the file "printstyle.css" you put:

* {display:none;}

Of course, it won't work in older browsers which don't support print stylesheets, or if CSS is disabled, but apart from that, the method works well and probably covers the vast majority of your users (even if they have javascript disabled!).

OR

Useful Methods For Preventing Image theft

1. Put desired image in an external stylesheet
(a) Put an div in the HTML page. (b) Put a single-pixel blank image in the div. (c) In an external CSS style sheet, make the div's background image the actual image to display. Eg:

HTML page head: link to the style sheet

<link href="/style/main.css" rel="stylesheet" type="text/css" />


HTML page body: display div with blank image

<div id="x1" class="x"><img src="/images/blank.gif" width="150" height="250"></div>


CSS sheet: display the background image

#x1
{ background: transparent url(/images/protect/pic.jpg) top left no-repeat; }


This method will mean that a right-click "Save Image", or a drag-and-drop will only yield the blank.gif image. It also means that the filename of the protected image will only be in the CSS style sheet, not the HTML page - most people won't find it. It requires no javascript.

---

2. Use a CSS print style to prevent images being printed with the page (could also use an external stylesheet)

This will not be activated if the user has CSS turned off (or has an ancient browser), but since the original protected images were put there by CSS in the first place, then nothing will be displayed anyway. So they still can't print them!

HTML page head:

<style media="print" type="text/css">
div.x {display:none}
</style>


---

3. Kill that damn Image Toolbar in Internet Explorer

HTML page head:

<meta http-equiv="imagetoolbar" content="no" />


---

4. Prevent search engine robots from caching images

HTML page head:

<meta name="robots" content="index, follow, noimageclick, noimageindex" />


or robots.txt file:

User-agent: *
Disallow: /images/protect/


---

5. Prevent hotlinking to images from outside your website


.htaccess file: on Apache servers

When a request is made for an image from outside the website, a different image, stolen.gif is served (basically saying that this image was stolen from www.example.com)

options FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_URI}!images/stolen\.gif$
RewriteCond %{HTTP_REFERER} .
RewriteCond %{HTTP_REFERER}!^http://(www\.)?example\.com/? [NC]
RewriteRule images/ http://www\.example\.com/images/stolen\.gif [R,L]


Or:
Another way to refuse access to those images.

SetEnvIf Referer "^$" local_ref=1
SetEnvIfNoCase Referer "^http://(www\.)?example\.com/" local_ref=1
<FilesMatch "\.(gif¦jpg)">
Order Allow,Deny
Allow from env=local_ref
</FilesMatch>
0
 
LVL 3

Accepted Solution

by:
StaticVortex earned 1140 total points
ID: 33131866
There is no solution which will stop someone from clicking Alt-PrtScn and then cropping the photo manually from the captured screen shot.

There are also lots of other ways of getting images from the webpage such as cilcking F12 on IE8 and finding the source of the file.

0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

Turn A Profile Picture Into A Cartoon Using Photoshop And Illustrator This tutorial will teach you how to make a cartoon style image out of a regular picture. I have tried to keep the tutorial as simple as possible. I used Adobe CS4 for this tuto…
Dramatic changes are revolutionizing how we build and use technology. Every company is automating, digitizing, and modernizing operations. We need a better, more connected way to work together as teams so we can harness the insights from our system…
The purpose of this video is to demonstrate how to prevent comment spam on a WordPress Website. This will be demonstrated using a Windows 8 PC. Plugin Akismet will be used. Go to your WordPress login page. This will look like the following: myw…
The purpose of this video is to demonstrate how to set up an RSS Feed on a WordPress Website. This will be demonstrated using a Windows 8 PC. Feedburner will be used for this demonstration. Go to your WordPress login page. This will look like the…

660 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