In the application I work on, we have several different places a user can print from. In all these cases we are using the same workflow of opening a new window(or tab), writing whatever we need to print to the document of the new window, and then we call
$(w.document).ready(function () {
w.focus();
w.print();
w.close();
});
The issue I'm seeing is that in Chrome, if I close the tab or window that is opened for the print preview instead of clicking the cancel button, Chrome is still blocking the javascript on my parent window.
It is similar to the issue described here:
Google Chrome blocks ajax requests when print preview is opened on child window
We are experiencing this issue as well, but I believe this is a result of how we are implementing printing in a new window and the way Chrome's print preview works. In IE and Firefox, the print window displays the modal dialog, and you are not able to do anything in the parent window until the print window is closed. Similarly chrome is blocking use of the parent window until the print preview is cancelled. However I would expect closing that tab or window to work the same as cancelling the print.
Has anyone else had this issue or know of a good solution?
Thank you!
Chrome print is usually an extension page so there is no dom attachment happening in your existing page. You can trigger the print command using command line apis(window.print()) but then they have not provided apis for closing it becoz of vary reason like choosing print options, print machine,count etc.
The problem is that there is an in-browser print dialogue within the popup window. If you call
window.close()
immediately then the dialogue is not seen by the user. The user needs to click "Print" within the dialogue. This is not the same as on other browsers where the print dialogue is part of the OS, and blocks thewindow.close()
until dismissed - on Chrome, it's part of Chrome, not the OS.This is the code I used, in a little popup window that is created by the parent window:
Use this code to return and reload the current window:
i've mandained some similar page (classic asp...)
my approach was to use Q promise directly on the popup.
For example my problem was that the popup i wanted to print close itself too fast ... and the print previw was empty, i solved this way :
Caller :
Popup (at the end of the page):
I think that your "parent lock" could be solved in a similar way
i would try :
that makes "the print" and "the close" async... so the parent will be immediately "unlocked"