I want to print DIV content of a page.What i do is retrieve contents of the div using JS and pass it to new window obj on which i call .print(). THe Text contents and images are displayed as such. Just when i add this line to retrieved div contents
<link href="myprintstyle.css" rel="stylesheet" type="text/css">
the print preview is blank. I tried adding other stylesheets as well,same result. Whatever style sheet reference i add to print html contents,same result -blank preview page. here is My JS code to print page contents.
var printDivCSS = new String ('<link href="myprintstyle.css" rel="stylesheet" type="text/css">');
function Popup(htmldata)
{
var mywindow = window.open('test', 'eChallanReceipt', 'height=800,width=800,top=20;left=20');
var str ="<html><head><title>test</title>";
str+= "</head><body>"+ printDivCSS + htmldata+"</body></html>";
mywindow.document.write(str);
mywindow.document.close(); // necessary for IE >= 10
mywindow.focus(); // necessary for IE >= 10
mywindow.print();
mywindow.close();
return false;
}
Please suggest some fix. I want to style the print content. Browser: Chrome
The same code is working in Mozilla. But in Chrome i am facing this issue.