How to display block on print?

Now there is a script for printing, but for some reason some computers the button opens the print window but immediately closes. What's the problem?
function Popup(data)
{
 var mywindow = window.open(", 'Reference', 'height=400,width=600');
mywindow.document.write('<html><head><title>Reference</title>');
 mywindow.document.write('<style>tr{border: 1px solid black} td{border: 1px solid black; font-size:10px}</style>');
 mywindow.document.write('</head><body >');
mywindow.document.write(data);
mywindow.document.write('</body></html>');
 mywindow.document.close(); // necessary for IE >= 10
 mywindow.focus(); // necessary for IE >= 10
mywindow.print();
mywindow.close();
 return true;
 }
April 3rd 20 at 17:39
1 answer
April 3rd 20 at 17:41
Use a better library Print.js

Find more questions by tags JavaScriptjQuery