My GWT JavaScript app prints reports by opening a new browser window programmatically, filling it with the report I want to print, and then calling window.print:
native void openPrintWindow(String contents) /*-{
var printWindow = window.open("", "PrintWin");
if (printWindow && printWindow.top) {
printWindow.document.write("<html><head><title>Report Card Print Window</title></head><body>");
printWindow.document.write(contents);
printWindow.document.write("</body></html>");
printWindow.print();
} else {
alert("The print feature works by opening a popup window, but our popup window was blocked by your browser. If you can disable the blocker temporarily, you'll be able to print here. Sorry!");
}
}-*/;
This works well, except that the icon in the title bar never changes from its initial swirling loading icon. How can I get it to realize that it's done loading?
I assume the problem is that it's not actually downloading anything, so it never "finishes," exactly. Is there something I can call like document.finalize or anything?
Yes, you need to call document.close() after the last document.write call.
https://developer.mozilla.org/en/document.write#Notes
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With