Skip to content Skip to sidebar Skip to footer

How Can I Disable Print-screen Functionality For A Webpage In All Browsers?

Using the following we can disable print-screens or screenshots in Internet Explorer:

Luckily no browser but IE allows you to access the clipboard via JavaScript so you are out of luck :)

By the way, if I visited your site and it messed up my clipboard (it overwrites anything in there, even if it's unrelated to your site) - I might have stored something in it that I've just cut from some file and I was going to paste in a different file and thanks to your site it would now be lost.

So, the conclusion is: Stop doing crap like that.


Solution 2:

It's an O.S. function, as well as a page function, and a print function so there are a few things you need to do - The steps below are specific for windows, however can be implemented in any O.S. with the same concept -

  1. Disable the print screen at an O.S. Level
Here are the steps of disable Print Screen key:

1.Copy the following registry to notepad and saved as a .reg file.
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
"Scancode Map"=hex:00,00,00,00,00,00,00,00,04,00,00,00,00,00,2a,e0,00,00,37,e0,\
00,00,54,00,00,00,00,00
2.Apply the registry 
3.Sign out and sign in again.

Then you need to block the browsers capability of capturing screens in the cases where chrome or edge or firefox have extensions that enhance print screens - And for extra measure, disable right click (I put it on document but you can put it per DOM

  document.addEventListener('contextmenu', 
                        event => event.preventDefault());
                        
                        window.addEventListener("keyup",kPress,false);
                    function kPress(e)
                    { 
                    var c=e.keyCode||e.charCode; 
                    if (c==44) event.preventDefault();
                    }

Then as an extra, to disable printing and items, you need to mark the print media as display none

@media print {
               .noprint {
                  visibility: hidden;
               }
            }

And if you want to be POPIA/GDPR compliant, you have to disable things like pdf download, object references and things so as a bonus item, Use PDF.js to render the pdf as html with full control over the rendering of the PDF, download and printing using the above

This reference allows password entries and successfully gave us full control over all features for capturing or saving information from protected sites

https://usefulangle.com/post/22/pdfjs-tutorial-2-viewing-a-password-protected-pdf


Solution 3:

Try onKeyPress catch the PrtScr button, and return false. It's not pretty but I think that would work.


Solution 4:

window.addEventListener("keyup",kPress,false);
function kPress(e)
{ 
var c=e.keyCode||e.charCode; 
if (c==44) alert("print screen");
}

Post a Comment for "How Can I Disable Print-screen Functionality For A Webpage In All Browsers?"