I am trying to print a page using this code
<html>
<head>
<script type="text/javascript">
function Popup()
{
var mywindow = window.open('', 'Ticket info', 'height=400,width=600');
mywindow.document.write('<html><head><title>my div</title>');
mywindow.document.write('<style type="text/css"> *{margin: 0; padding: 0;} body{padding: 3px; padding-left:20px;font:6px bold Arial;}</style>');
mywindow.document.write('<script src="http://code.jquery.com/jquery-latest.min.js"><'+'/script>');
mywindow.document.write('<script src="jquery-barcode.min.js"><'+'/script>');
mywindow.document.write('</head><body>');
mywindow.document.write('<div id="demo"></div>');
mywindow.document.write('<script type="text/javascript">$("#demo").barcode("1234567890128", "code39");<'+'/script>');
mywindow.document.write('</body></html>');
mywindow.print();
return true;
}
</script>
</head>
<body>
<input type="button" value="Print Div" onclick="Popup();" />
</body>
</html>
Basically, it will pop out of the window and show a preview of the page. the first attempt to download the print preview will not load the barcode, and when you cancel the first print preview, then right-click on the page and print the second print preview again, which will now display the barcode for printing. A.



I think the problem comes from this line:
mywindow.document.write('<script type="text/javascript">$("#demo").barcode("1234567890128", "code39");<'+'/script>');
when I comment on this line and add dummy text to the page. It will automatically appear in print preview on the first try.
, css. , .
, ? - ?