我有一些使用print.js打印元素的jquery代码,它工作正常,但我需要知道我是否可以检查打印窗口是否关闭并重新加载页面
printJS('print_paper', 'html'); //do stuff after close print window
字符串
pkbketx91#
有一个名为onPrintDialogClose的选项,它在“打印”对话框关闭后触发。
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 . }
nnsrf1az2#
我在下面的链接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.. } });
2条答案
按热度按时间pkbketx91#
有一个名为
onPrintDialogClose
的选项,它在“打印”对话框关闭后触发。字符串
nnsrf1az2#
我在下面的链接https://github.com/crabbly/Print.js/issues/348中尝试了slebetman的解决方案,它对我很好
字符串