Check for when a user has selected to print using javascript

前端 未结 2 1137
温柔的废话
温柔的废话 2020-12-10 00:05

When a user chooses \"File > Print\" on a browser such as Firefox or Internet Explorer, or clicks on a link that runs the below javascript

window.print();
         


        
2条回答
  •  生来不讨喜
    2020-12-10 00:45

    You can do:

    window.old_print=window.print
    window.print=function() {
        alert('doing things');
        window.old_print();
    }
    

    but this will only catch calls to print() from inside the page javascript.

    Did you try putting !important on print-specific stylesheet?

提交回复
热议问题