Print from iFrame in current window, and add callbacks for before print, and after print.
(function() {
var beforePrint = function() {
console.log('Functionality to run before printing.');
};
var afterPrint = function() {
console.log('Functionality to run after printing');
};
var ifr=''//iframe ref;
ifr.focus();
var cw=''//ifr.contentWindow
if (window.matchMedia) {
var mediaQueryList = cw.matchMedia('print');
mediaQueryList.addListener(function(mql) {
if (mql.matches) {
beforePrint();
} else {
afterPrint();
}
});
}
cw.onbeforeprint = beforePrint;
cw.onafterprint = afterPrint;
}());