I have a print button wich opens a new window with the content to be printed and after loading the included pictures (img-tag with src-attribute) calls window.print.
var newWindow = window.open('', 'MyTitle');
newWindow.document.open();
newWindow.document.write(myPrintContent)
newWindow.onload = function() {
newWindow.print();
}
newWindow.document.close(); // necessary for IE >= 10
newWindow.focus(); // necessary for IE >= 10
This works fine in every tested browser (Chrome, FF, IE) except Safari where the onload is triggered before the images are loaded (The DOM content is displayed correctly.).
The load event fires at the end of the document loading process. At this point, all of the objects in the document are in the DOM, and all the images, scripts, links and sub-frames have finished loading.
I tried to use onpageload but i get the same effect.
Is there a way to wait for all images to be loaded in safari?