I am looking to utilize a new window for printing a portion of HTML content.
var cssLink = document.getElementByTagName('link')[2];
var prtContent = document.getElementById('print_body');
var WinPrint = window.open('','','left=0,top=0,width=1000,height=auto,toolbar=0,scrollbars=0,status=0');
WinPrint.document.write(prtContent.innerHTML);
WinPrint.document.getElementsByTagName('head')[0].appendChild(link);
WinPrint.document.close();
WinPrint.focus();
WinPrint.print();
However, occasionally when WinPrint is ready to perform the system print, the CSS file has still not been loaded.
Is there a solution to this issue?