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.
Click "Edit" and then "Select All." Right-click the selected text and click "Copy." Open the HTML document for which you would like to disable the print screen ability. Paste the code anywhere between the head tags ( and ) of the document. Save the document.
Click on the "Keyboard" icon to open a window. Find the "FilterKey" option and turn it off.
Locate the Print Screen key on your keyboard. It's usually in the upper-right-hand corner, above the “SysReq” button and often abbreviated to “PrtSc.” Press the main Win key and PrtSc at the same time. This will take a screenshot of the entire current screen.
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:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With