Stop User from using "Print Scrn" / "Printscreen" key of the Keyboard for any Web Page

74,949

Solution 1

You can't disable screen grabbing from the Web browser, it would only be possible by installing additional software on the user's PC.

There are some IRM (Information Rights Management) tools available that do that e.g. by protecting Windows/DirectX API calls and also monitoring video memory such as Oracle IRM or such as Microsoft's IRM technology.

Especially the latter might be of interest as there is also a Rights Management Add-on for Internet Explorer.

But as other already said, any IRM/DRM technology is controversy and you should understand that it most often will limit or annoy your users.

Solution 2

I hate the "it's not possible" sentence. Here's all solutions combined to help you:

1- You can grab the solution from Haluk:

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

    }); }); 
</script>

HOWEVER, you hide body, but's already "printed" to clipboard. You can fire another event that copy some text to your clipboard, as you can see on this answer "Edit as of 2016" Click button copy to clipboard using jQuery , it's something like this:

function copyToClipboard() {
  // Create a "hidden" input
  var aux = document.createElement("input");
  // Assign it the value of the specified element
  aux.setAttribute("value", "Você não pode mais dar printscreen. Isto faz parte da nova medida de segurança do sistema.");
  // Append it to the body
  document.body.appendChild(aux);
  // Highlight its content
  aux.select();
  // Copy the highlighted text
  document.execCommand("copy");
  // Remove it from the body
  document.body.removeChild(aux);
  alert("Print screen desabilitado.");
}

$(window).keyup(function(e){
  if(e.keyCode == 44){
    copyToClipboard();
  }
}); 

This will block a part of your problem. If user focus on another object outside this windows he will be able to take screenshots. **But there's another solution to that as well, simply disable the hole body when window get's unfocused. Full solution, from your dear brazillian friend:

function copyToClipboard() {
  // Create a "hidden" input
  var aux = document.createElement("input");
  // Assign it the value of the specified element
  aux.setAttribute("value", "Você não pode mais dar printscreen. Isto faz parte da nova medida de segurança do sistema.");
  // Append it to the body
  document.body.appendChild(aux);
  // Highlight its content
  aux.select();
  // Copy the highlighted text
  document.execCommand("copy");
  // Remove it from the body
  document.body.removeChild(aux);
  alert("Print screen desabilitado.");
}

$(window).keyup(function(e){
  if(e.keyCode == 44){
    copyToClipboard();
  }
}); 

$(window).focus(function() {
  $("body").show();
}).blur(function() {
  $("body").hide();
});

Here's the example working:

Here i try to unfocus the window, on unfocus i hide content and show modal

Solution 3

This is not possible.

Solution 4

Thankfully, this outrageous idea is not possible to implement reliably, neither the "disable screen grab" part nor the "disable user's Firefox extensions" one. And even if it were, as @kbok points out in his comment above, you don't have a right to do this.

The only way to protect your content online is copyright laws - mentioning those is often enough to scare people away from misusing it! - or not showing it at all.

Solution 5

Try this

$(document).keyup(function(e){
  if(e.keyCode == 44) return false;
});

Hope it works

Share:
74,949
Knowledge Craving
Author by

Knowledge Craving

Lifetime Student #SOReadyToHelp

Updated on July 08, 2022

Comments

  • Knowledge Craving
    Knowledge Craving almost 2 years

    I am currently doing a project, in which I need to stop the user from taking the snapshot of any Web Page, for which he can use the "Print Scrn" / "Printscreen" key available in any of the normal keyboards.

    I have been trying to find its solution, but in vain. If possible, I need to take into account of the "Screengrab" add-on of the Firefox browser, by stopping it also.

    Any help is greatly appreciated, and I am using PHP (as server-side language) & jQuery for my project.