1

I want to disable print screen on a web page in a website. I have used many type codes for doing this but I could not succeed:

<script type="text/javascript"> 
    $(document).ready(function() {
        $(window).keyup(function(e) {
            if (e.keyCode == 44) {
                alert('keyup');
                return false;
            }
        }); 

        $(window).keydown(function(e) {
            if (e.keyCode == 44) {
                alert('keydown');
                return false;
            }
        });
    });
</script>

This code is not working and similar other attempts I tried also did not work. My question is that - is it possible or not? If yes, then how do I do this?

Ivaylo Slavov
  • 8,839
  • 12
  • 65
  • 108
  • 1
    Why would you even want to do this? I'm genuinely interested. Even if you succeed in blocking a key combination - what about software that is used for screen capture? – Peter Trobec Jan 06 '14 at 09:56
  • Printscreening is done by the OS, not by the browser. Even if you intercept the printscreen key in the browser, the OS will already have handled it and captured whatever's on screen. – senshin Jan 06 '14 at 09:56
  • http://stackoverflow.com/questions/455623/how-can-i-prevent-users-from-taking-screenshots-of-my-application-window – Aaron Lee Jan 06 '14 at 09:57
  • Since it is not possible, but to protect your online contents you can get copyrights as @Pekka 웃 mentioned in his [answer](http://stackoverflow.com/a/3131033/1671639) – Praveen Jan 06 '14 at 10:01
  • The only easy alternative I can think of is adding an empty png or something to the clipboard by JavaScript, the problem however is that using the clipboard requires permission by the user. The best thing you can do in my opinion is adding watermarks to any 'private' data or images and add a legal disclaimer or make a user accept terms and conditions before accessing the data. – Marvin Brouwer Jan 06 '14 at 10:10

2 Answers2

5

No, it is impossible to prevent someone from taking a screenshot while viewing your website.

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
3

No you can not, Not from a webpage.

Consider rethinking whether you really need to do this.

The internet is for sharing.

Suhas Gosavi
  • 2,170
  • 19
  • 40