I need to print a page created dinamically with JavaScript and Html. My problem is that sometimes it shows a blank page. I think that it is because the "window" isn't loaded yet. How can printing wait until the window is loaded?
I tried to add the method wait()
but the problem is the same.
This is the method for printing page:
function printpage(){
var panel;
panel =document.getElementById("cajaticket").innerHTML;
var mywindow = window.open('', 'Print');
mywindow.document.write('<html><head><link rel="stylesheet" href="css/extras/ticket.css"></head><body>');
mywindow.document.write(panel);
mywindow.document.write('</body></html>');
mywindow.document.close();
mywindow.focus();
mywindow.print();
mywindow.close();
panel=null;
}
It should always print the window,but currently, it only works sometimes.