I'm looking for a way to automatically close the current tab in Chrome when the user clicks on the print
button in the Print Dialog. I've tried using window.print()
and setTimeout()
, but this approach closes the dialog even if the print is canceled by clicking on the CANCEL
button.
Is there a different solution that might work better?
Here's what I've attempted so far:
function printThis(){
window.print();
setTimeout(function(){
window.close();
},5000);
}