无论如何要等待 print 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 .
}
我在下面尝试了 slebetman 的解决方案 link https://github.com/crabbly/Print.js/issues/348,它对我来说效果很好
let focuser = setInterval(() => window.dispatchEvent(new Event('focus')), 500);
printJs({
printable: url,
onPrintDialogClose: () => {
clearInterval(focuser);
// do your thing..
},
onError: () => {
clearInterval(focuser);
// do your thing..
}
});
我有一些 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 .
}
我在下面尝试了 slebetman 的解决方案 link https://github.com/crabbly/Print.js/issues/348,它对我来说效果很好
let focuser = setInterval(() => window.dispatchEvent(new Event('focus')), 500);
printJs({
printable: url,
onPrintDialogClose: () => {
clearInterval(focuser);
// do your thing..
},
onError: () => {
clearInterval(focuser);
// do your thing..
}
});