How can I wait for the image to load in my new window before printing via child.print()?
Posted
by
libertas
on Stack Overflow
See other posts from Stack Overflow
or by libertas
Published on 2012-09-10T20:43:16Z
Indexed on
2012/09/10
21:38 UTC
Read the original article
Hit count: 192
$("#print").on('click', function () {
var child = window.open("image.jpg", "_blank", "location=0,toolbar=0,scrollbars=1,fullscreen=1,menubar=0");
//any way to know/wait for image to load?
child.print();
});
Any way for my parent window to know that the child window has completed loading the image prior to calling .print()? If they were trigger happy they would end up printing a blank page.
I've tried both:
child.attachEvent("onload", function () { child.print(); });
and
child.attachEvent("DOMContentLoaded", function () { child.print(); });
//(found this online, apparently it's Firefox only, still didn't work)
© Stack Overflow or respective owner