Possible Duplicate:
Jquery: how to check if a newly opened window has been fully loaded? / window loads an external page (like www.yahoo.com)
So i have this function, that takes some html codes, and the it will open up a new window and place the code in the window, and then prompt the print function. However, sometimes, the print css doesn't get loaded, and the print doesn't build the proper page. Is there any way we can see if the newly opened window has loaded all the contents?
function printer(el)
{
print_window= window.open();
var print_css = '<link rel="stylesheet" href="css/bootstrap.css" type="text/css" />';
print_css = print_css + '<link rel="stylesheet" href="css/main.css" type="text/css" />';
print_css = print_css + '<link rel="stylesheet" href="css/print.css" type="text/css" media="print" />';
print_window.document.write("<html><head>" + print_css + "</head><body>" + "<div class='contents'>" + el + "</div>" + "</body> </html>");
print_window.document.close();
print_window.focus();
print_window.print();
print_window.close();
}
Thanks