• Custom Printed T-shirts
  • Seo Expert
  • Bisen Infotech
  • Khaali Paper

Disable print option using javascript

Disable print option in browser using javascript. The alert() method displays an alert box with a specified message (Sorry, you are not authorized to take a Print).

To disable print option use following below code:-

<script>
    $(document).on('keydown', function(e) {
        if(e.ctrlKey && (e.key == "p" || e.charCode == 16 || e.charCode == 112 || e.keyCode == 80) ){
            alert("Sorry, you are not authorized to take a Print");
            e.cancelBubble = true;
            e.preventDefault();
            e.stopImmediatePropagation();
        }
    });
</script>

Disable print option pdf using javascript

You can customize this code further as per your requirement.