How to Disable the CTRL+P using javascript or Jquery?

后端 未结 11 1120
一生所求
一生所求 2020-12-31 06:17

Here I tried to disable the Ctrl+P but it doesn\'t get me alert and also it shows the print options

jQuery(document).bind(\"keyup keydo         


        
11条回答
  •  梦谈多话
    2020-12-31 06:21

    You can't prevent the user from printing, but you can hide everything when the user prints the document by using simple CSS:

    
    

    Updated fiddle.

    If you would like to show the visitor a custom message when he/she try to print rather then just a blank page, it's possible with client side code but first wrap all your existing contents like this:

    And add such a container with the custom message:

    You are not authorized to print this document

    Now get rid of the