Print.js icon indicating copy to clipboard operation
Print.js copied to clipboard

firefox onPrintDialogClose and redirect not working

Open ilongoat opened this issue 4 years ago • 2 comments

hi there wonderful job - I really appreciate your work.

Just encountered a small bug

on FIREFOX ( latest version mc & windows )

printJS({printable:'dummy.pdf', type:'pdf', onPrintDialogClose: () => window.location='whatever.html'});

not working

if I click in the Adressbar and afterwards in the website -> trigger is fired and reload is done

so somehow firefox loses the focus on the current window

Any help very appreciatet

My workaround this time SetTimeout function .. fires after 11 seconds ( enough time for the users to print the socument )

ilongoat avatar Jul 13 '21 08:07 ilongoat

Hi,

I think Firefox main document doesn't get the focus back after iframe is removed.

Iframe is focused at the beginning in line 55 and apparently it's not necessary for all the browsers because I commented this line and now it's working great on Firefox 91.0. In all cases, Chrome works with or without.

https://github.com/crabbly/Print.js/blob/6502c73c7e1ba87346fe4913fa5de6220936095b/src/js/print.js#L53-L79

So the question is: Why the focus in line 55 is needed ? Is this needed for all browsers ? (I also checked Chrome, Chromium, Edge on Linux)

qdelcourte avatar Aug 17 '21 15:08 qdelcourte

I removed iframeElement.focus() in my typescript port of this library in https://github.com/daphnesmit/prntr

daphnesmit avatar Jan 22 '22 15:01 daphnesmit