printing - iOS 8 Safari print redirect doesn't stop javascript execution -
i have need provide ability print label on successful save , after print redirect search page. works in chrome, firefox, ie, ios 6/7 safari, etc. however, seems ios 8 no longer stops execution of javascript when window.print() issued javascript.
if navigate this jsfiddle example ios 8 safari (connected computer can view console logs) , click print button see console.log trigger when print dialog up. if want print , navigate print wrong screen unless have delay gives plenty time nail print isn't acceptable in case.
i did artificial delay because in ios 6/7 seemed print dialog stop execution of javascript. in case 500ms plenty create work.
has else seen issue when doing similar thing in ios 8 safari? have introduced new event hear utilize this?
// illustration code window.print(); settimeout(function() { console.log('this should print after print issued in ios print dialog.'); }, 500);
you can utilize window.matchmedia
(caniuse link), combined window.onbeforeprint
, window.onafterprint
(for before ie support). reference using matchmedia can found here , here.
to satisfy using matchmedia
ios, utilize nested events. first, hear media type alter print
. then, within callback, hear media alter screen
.
if (window.matchmedia) { var printquery = window.matchmedia('print'); printquery.addlistener(function() { var screenquery = window.matchmedia('screen'); printquery.addlistener(function() { //actions after print dialog close here }); }); }
javascript printing ios8 mobile-safari
No comments:
Post a Comment