Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tab opened for printing perpetually shows "loading" icon

Tags:

javascript

gwt

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?

like image 238
Riley Lark Avatar asked Dec 03 '25 18:12

Riley Lark


1 Answers

Yes, you need to call document.close() after the last document.write call.

https://developer.mozilla.org/en/document.write#Notes

like image 200
hugomg Avatar answered Dec 06 '25 09:12

hugomg