这个功能没有使用过,网上看到的,记录一下

 1 var beforePrint = function() {
 2     console.log('Functionality to run before printing.');
 3 };
 4 
 5 var afterPrint = function() {
 6     console.log('Functionality to run after printing');
 7 };
 8 
 9 if (window.matchMedia) {
10     var mediaQueryList = window.matchMedia('print');
11     mediaQueryList.addListener(function(mql) {
12         if (mql.matches) {
13             beforePrint();
14         } else {
15             afterPrint();
16         }
17     });
18 }
19 
20 window.onbeforeprint = beforePrint;
21 window.onafterprint = afterPrint;

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-12-28
  • 2021-12-14
  • 2021-06-16
猜你喜欢
  • 2021-06-23
  • 2021-10-24
  • 2022-01-20
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案