Reputation: 362
I have some jquery code using print.js for printing an element and its working fine but I need to know if I can check if the print window is closed and reload the page
printJS('print_paper', 'html');
//do stuff after close print window
Upvotes: 1
Views: 2022
Reputation: 485
I tried slebetman's solution in the following link https://github.com/crabbly/Print.js/issues/348 and it works fine with me
let focuser = setInterval(() => window.dispatchEvent(new Event('focus')), 500);
printJs({
printable: url,
onPrintDialogClose: () => {
clearInterval(focuser);
// do your thing..
},
onError: () => {
clearInterval(focuser);
// do your thing..
}
});
Upvotes: 2
Reputation: 22323
There is a option called onPrintDialogClose
which is fire after Print dialog close.
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 .
}
Upvotes: 2