I know that there is already the same question but none of that answers worked for me.
The problem:
I have an app in angular for firefox where I open a window to print it. The problem is that I dont want to print it more than once and also dont want that this view to be visible to the user. So I would like to open this new window behind the main app.
My code:
let printContents2, popupWin2;
printContents2 = document.getElementById('to-print').innerHTML;
popupWin2 = window.open('', '_blank', 'top=10000,left=10000,height=1px,width=1px');
popupWin2.document.open();
popupWin2.document.write(`
<html>
<head></head>
<body style='width=350px' onload="window.print();window.close();">${printContents2}</body>
</html>`
);
popupWin2.document.close();
What I have tried:
popupWin2.blur();
window.focus();
onload="window.print();window.close();"
Thank you in advance.