Printing child window after loading images in Safari

I have a print button that opens a new window with printable content and after loading the included images (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 well in every browser tested (Chrome, FF, IE) except Safari, which triggers the load on image load (DOM content renders correctly).

The load event is fired at the end of the document loading process. At this point, all objects in the document are in the DOM and all images, scripts, links, and subframes have finished loading.

I tried using onpageload, but I get the same effect.

Is there a way to wait for all the images to be uploaded to safari?

+3


source to share





All Articles