问题
I need to execute doSomethingFunc
, when afterPrint happens. My code is working fine on all browsers, except the current Safari-Versions (Safari 10.1 on OSX and the Safari Browser from iOS 10.3). It seems that the event listeners (at least for print) are not called for these two browsers.
const mediaQueryPrint = window.matchMedia('print');
mediaQueryPrint.addListener((mql) => {
if (!mql.matches) {
setImmediate(doSomethingFunc);
}
});
window.print();
The code above works perfectly with OSX Safari 9.1.2 and Safari from iOS 10.2. But not with the current versions.
Has somebody noticed something similar? Or do I have to improve my code for the current Safari versions?
My guess is, that this is a Safari bug, since there is a corresponding note in the Safari 10.1 changelog chapter Accessability.
回答1:
Did you not want to call
setImmediate(doSomethingFunc);
when
mql.matches
is True? Why the '!' then?
来源:https://stackoverflow.com/questions/43386499/safari-window-matchmedia-handler-not-called