26

Possible Duplicate:
How do i prevent from printscreen of my webpage?

I want to prevent users from taking screen shots of a web-page. What should be the code I have to place in that .html file?

What should be the code to prevent button press like print screen? Because many website prevents users from pressing any keys.

Community
  • 1
  • 1
Debadyuti Maiti
  • 1,099
  • 4
  • 18
  • 30
  • 1
    Actually I hear there is a way to make a "watermark" to an image that renders to black when you screenshot it, if you make a div that covers your entire page (width:100%; height:100%) and places this "watermark" with a transparent background and it will no longer be possible to screenshot your website. Of course, anyone with firebug or inspect object on chrome could simply delete that div and take screenshots as normal. I guess you could recreate that div in a timer and obfuscate the code. But in all there is no way to make this 100% impossible. – Hoffmann Sep 14 '12 at 17:49
  • 1
    @Hoffmann How about when activating some other application window on the screen and then hitting `Print screen`? – Teemu Sep 14 '12 at 17:51
  • 8
    @Hoffmann if you can see if on the screen you can capture it. period. – Ben D Sep 14 '12 at 17:51
  • As I said I heared there is a way to make this, I don't know how to do it myself and a quick google search yields nothing. Also @Ben D, HDCP prevents screenshots from DRMed blu-rays. You can bypass it today but for some time it was simply impossible – Hoffmann Sep 14 '12 at 17:53
  • @Hoffmann if something is being output by your video card it can be captured. As I mentioned in my answer, there are ways of making it more difficult, but never impossible... and over the web you can't even really make it that difficult. The same goes for audio... it has to be output, so it can be read – Ben D Sep 14 '12 at 18:31
  • @Hoffmann and on the issue of HDCP, I believe this was a hardware licensing agreement (data wouldn't be transmitted at all to non HDCP devices), though it succeeded in making it quite hard to capture data because they dictated the rules of your hardware. – Ben D Sep 14 '12 at 20:00
  • 1
    You also can't stop them taking a picture of the screen with their mobile phone, or copying the information off by hand onto a piece of paper with a pencil. – Donal Fellows Sep 15 '12 at 08:43
  • 3
    Simple. Don't publish any content worth stealing. Most of the web uses this technique, IMHO. – FastAl Sep 14 '12 at 18:02
  • You could do some really fast random flickering pixels where it goes too fast for your eye to see, but when captured it would see a lot of noise – Joe Love May 05 '21 at 17:34

3 Answers3

20

Screenshots are not controlled by the web browser, they are controlled by software running on the user's operating system and cannot be remotely controlled by a web server.

JSK NS
  • 3,346
  • 2
  • 25
  • 42
  • 14
    Somehow Netflix’s browser-based version has done it where captures just give a black image with no content. Possibly, though, this is something built-in to the player plug-in so I guess it would depend on your content and whether you’re trying to block the whole page or just images or other bits. – DonP Jul 16 '21 at 21:34
  • Yes, in the case of netflix, it is not the browser blocking it, but a heavy client, a "software running on the user's operating system". That software happens to be a plugin to a browser, yet it is still a software, not some pure web. – chrslg Jan 12 '23 at 18:32
9

It is possible. Try this css3 feature.

@media print {
    html, body {
       display: none;  /* hide whole page */
    }
}
Ryan M
  • 18,333
  • 31
  • 67
  • 74
Nelson
  • 49,283
  • 8
  • 68
  • 81
  • 111
    This code does not prevent making screenshots, it prevents printing the screen by using the browsers Print function. Marking this as an aswer is misleading I think – Daniel Leiszen Jul 16 '17 at 22:19
  • 9
    This works with print command not with "print screen"! – Chella Aug 08 '17 at 12:34
  • 1
    @Greg please do not edit posts to change the actual answer. If you want to post that answer, post it yourself (on the duplicate target, since this is closed); don't edit it into someone else's answer. – Ryan M Jul 07 '22 at 10:48
0

You cannot block the print screen button or the snipping tool in Windows 7 or the Grab application included with Mac OS or...

DanielBlazquez
  • 1,045
  • 1
  • 13
  • 22