Reputation: 2235
I have a scenario where in my webpage i do a window.open() which opens up another window whose onLoad()
invokes window.print()
. In this flow, the parent window
remains frozen disallowing any links to be clicked on. How to I get away with this problem?
For example:
An HTML page has three links: create, manage and print. The javascript code for the print link is the following:
var url = '/actions/print/';
var win = window.open(url,"Title_","resizable=yes,scrollbars=yes,directories=no,titlebar=no,location=no,status=no,menubar=no,width="+width+",height="+height);
now, the HTML rendered by /actions/print
is:
<html><body onload="window.print();"> ... Content goes here ...</body></html>
So as you can see, clicking on print opens up a new window and triggers print immediately. In this state, when i go back to parent window with three links and try to click on other links, it doesn't work and appears frozen.
Upvotes: 14
Views: 3089
Reputation: 494
You can't resolve this issue on OS X. Which I am pretty sure you only tested on.
Here is how I came to that conclusion after testing on different browsers and plateforms.
Chrome, Safari and Firefox on OS X did not allow interactivity with parent window when a print modal was opened from a child window (closing the print dialog, but not the pop up, re-enabled interactivity).
IE8 on Win XP, IE11, Chrome and Firefox (all on Win7) always allowed interactivity with this same scenario.
This led me to believe this was an OS X restriction or recommendation. On further research, here is what I found on developer.apple.com, confirming my doubts:
A document-modal dialog prevents the user from doing anything else within a particular document. The user can switch to other documents in the app and to other apps. Document-modal dialogs should be sheets, which are described in Using Document-Modal Dialogs (Sheets).
Use a sheet when multiple documents can appear in a single window at different times. For example, a tabbed browser can display different documents in a single window at different times. A sheet is appropriate in this situation, even though it applies to only the document that is currently visible in the window. Because users must in effect dismiss the current document before viewing a different document in the same window, they should first dismiss the sheet.
Upvotes: 18