I want to print the contents of the DIV on the page. What I am doing is getting the contents of the div using JS and passing it to a new obj window where I call .print (). Text content and images are displayed as such. Just when I add this line to get the contents of the div
<link href="myprintstyle.css" rel="stylesheet" type="text/css">
Print preview is empty. I also tried adding other style sheets, the same result. Whatever link to the stylesheet I add to print the contents of html, the same page with a preview of the results. here is my JS code to print the contents of the page.
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();
Please suggest some corrections. I want the style of print content. Browser: Chrome
The same code works in Mozilla. But in Chrome, I ran into this problem.
source share