views:

24

answers:

0

Seeing on various sites some web JavaScript for displaying a window (say once a button is pressed) and I don't understand why you would call window.open twice, the first is normally to blank or some static error page, the second is to the actual content somewhat more heavy weight like a pdf.

Is this normal, should it work?

currentDialog = window.open("about:blank", name, "width=20 height=20 left=50 top=50");
if (currentDialog != null)
  currentDialog.close();
currentDialog = window.open("about:blank", name, "width=20 height=20 left=50 top=50");

The thing is we have a BHO and something changed recently (IExplorer/PDF/web pages) so that a bunch of customers think our BHO is breaking the web page. I don't like that idea and as far as I can figure this JavaScript is wrong currently. Even when our BHO is uninstalled this simplified JavaScript doesn't work for me

Creating a simple BHO with tracing it appears that the second Window Open (causing DocumentLoadComplete) is happening on the same site as the first opened window but after the OnQuit event. So I get to the point where I don't see any way I could fix my BHO to make this work all the time - sometimes the second window.open might be slow enough and work, but that is only luck.

Changing the JavaScript to

currentDialog = window.open("about:blank", name, "width=20 height=20 left=50 top=50");
if (currentDialog != null)
  currentDialog.close();
while(!currentDialog.closed);
currentDialog = window.open("about:blank", name, "width=20 height=20 left=50 top=50");

The first window closes fully, BHO site is destroyed, and then when the new window is opened a new site is created and all is well.

So now I'm at the point where it seems we must help people fix their web pages, but I'm not sure if it is really broken or some other issue I'm missing.

Related to my earlier question How to guarantee that a named popup window is closed so that a new window with the same name can be created?