I have an app with possibility to print some contents. For that purpose I'm opening a new window and inserting there some layout.
// function body
const printWin = window.open('');
printWin.document.body.appendChild(el);
printWin.focus();
printWin.print();
printWin.close();
The problem is that unit print window is close the app is totally blocked (since it's executed synchronously).
I've tried to make
printWin.addEventListener('DOMContentLoaded', () => {
printWin.focus();
printWin.print();
printWin.close();
})
However, this event doesn't seem to be fired. How do I print and immediately close window while not causing execution block?
.print()method.