So let's start with the code:
var mywindow = window.open('', 'PRINT', 'height=600,width=800');
mywindow.document.write('<html><head><base href="/" /><title>' + document.title + '</title>');
mywindow.document.write('<style type="text/css" media="print" />table { width: 100%; }</style>');
mywindow.document.write('</head><body >');
mywindow.document.write('<h1> Returns for Today </h1>');
mywindow.document.write(document.getElementById(printableArea).innerHTML);
mywindow.document.write('</body></html>');
mywindow.document.close(); // necessary for IE >= 10
mywindow.focus(); // necessary for IE >= 10*/
mywindow.print();
mywindow.close();
return true;
The code is pretty working with this output
And then when I change the css to an external stylesheet like this:
From mywindow.document.write('<style type="text/css" media="print" />table { width: 100%; }</style>');
To mywindow.document.write('<link rel="stylesheet" href="assets/css/printstyles.css" type="text/css" />');
I get a blank print page:
But if I comment the line
//mywindow.print();
//mywindow.close();
I get this:
Meaning, the external stylesheet is working.
The external stylesheet only includes
table { width: 100%; }
Any idea why it is not working? Any help would be much appreciated.