繁体   English   中英

无论如何要等待打印 window 在 print.js 中关闭

[英]Is there anyway to wait for print window to close in print.js

我有一些 jquery 代码使用 print.js 打印元素并且它工作正常但我需要知道我是否可以检查打印 window 是否已关闭并重新加载页面

printJS('print_paper', 'html');
//do stuff after close print window

有一个名为onPrintDialogClose的选项在打印对话框关闭后触发。

printJS({
    type: "html",  // Include other option if needed like style , css .....
    onPrintDialogClose: closedWindow 
  });
}

function closedWindow() {
  alert("Window is closed "); // What ever you want to do after window is closed .
}

我在以下链接https://github.com/crabbly/Print.js/issues/348中尝试了 slebetman 的解决方案,它适用于我

let focuser = setInterval(() => window.dispatchEvent(new Event('focus')), 500);

printJs({

    printable: url,

   onPrintDialogClose: () => {

   clearInterval(focuser);

   // do your thing..

},

onError: () => {

   clearInterval(focuser);

    // do your thing..

  }

});

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM