30

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.

9
  • 2
    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
    Commented Sep 14, 2012 at 17:49
  • 1
    @Hoffmann How about when activating some other application window on the screen and then hitting Print screen?
    – Teemu
    Commented Sep 14, 2012 at 17:51
  • 9
    @Hoffmann if you can see if on the screen you can capture it. period.
    – Ben D
    Commented Sep 14, 2012 at 17:51
  • 4
    Simple. Don't publish any content worth stealing. Most of the web uses this technique, IMHO.
    – FastAl
    Commented Sep 14, 2012 at 18:02
  • 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. Commented Sep 15, 2012 at 8:43

3 Answers 3

23

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.

5
  • 21
    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.
    – user5175034
    Commented Jul 16, 2021 at 21:34
  • 1
    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
    Commented Jan 12, 2023 at 18:32
  • 1
    HBO's Max streaming service is also able to blackout streaming content. This works even if you manually disable JS and CSS with web developer tools so it must be a very low-level graphics plugin. Commented Sep 21, 2023 at 4:08
  • any update on how to implement it? Commented Oct 3, 2023 at 4:40
  • 1
    Streaming services generally use Widevine. Most desktop browsers implement Widevine L3 (less secure) with a native software plugin. Most Android devices implement Widevine L1 (more secure) with a deeper Trusted Execution Environment (TEE) integration. Apple's equivalent is FairPlay ( developer.apple.com/streaming/fps ). The goal of DRM is to restrict your ability to copy and share, so it makes sense for DRM to disable as many forms of screenrecording/screenshotting as they can. Widevine does not work for general DOM content and can't be used to prevent webpage screenshots. Commented Jan 4 at 19:21
8

It is possible. Try this css3 feature.

@media print {
    html, body {
       display: none;  /* hide whole page */
    }
}
3
  • 115
    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 Commented Jul 16, 2017 at 22:19
  • 9
    This works with print command not with "print screen"!
    – Chella
    Commented Aug 8, 2017 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
    Commented Jul 7, 2022 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...

Not the answer you're looking for? Browse other questions tagged or ask your own question.