How do I detect the print preview mode on a child page?

Question: From page A I have a link to page B, on page B it calls window.print () on load which opens print preview mode. My question is on page A, is there an easy way to find out if the print preview mod on page B is currently open or not? (I only need this to work in Chrome)

Background: The reason I need to do this is because there is a problem with Google Chrome blocking the parent Ajax page when it has a child page that has a print preview open. Questions related to:

Chrome browser cannot make a server call when opening preview

Google Chrome blocks ajax requests when preview is open in child window

https://code.google.com/p/chromium/issues/detail?id=139706

There is no easy way to completely fix the problem, so I only want to know if print preview is open and prevent users from closing print mode on page B before moving forward on page A.

+3


source to share


1 answer


It looks impossible. Chrome doesn't just block ajax execution, but it also stops processing all scripts on page A.

I think its best to have instructions on page B so that the user can print the page. Any Javascript triggered print will pause Javascript execution on Page A.

A possible solution would be to display the message on page A before opening page B in anticipation of this behavior.



Edit : Extracting information from the comment below

After further reflection, the best solution would be: On page B, in the script that calls window.print (), just before the call to print, sends information to page A, telling it that this will happen, so that page A can take appropriate action.

+1


source







All Articles