Modal dialogs in IE

HTML Add comments

Modal dialogs in Internet Explorer are a somewhat curious creature. Here are some of the problems that I have encountered and their workarounds:


Problem Solution / Workaround

Postback of a form within a modal dialog causes a new window to open

Use one of the following:

  • Add a <base target="_self"> fragment in the <head> element of your page
  • Put all of the dialog’s content within an iframe

Navigation to a new page within a modal dialog causes a new window to open

Put all of the dialog’s content within an iframe

The DISPID_NEWWINDOW2 event fired by the Internet Explorer COM component (often abstracted by the WebBrowser control) is not fired for modal dialogs, which means that applications that host Internet Explorer cannot capture the creation of modal dialogs to add their own window decorations or object model to window.external

No solution is known to actually capture the event.

As for accessing window.external within modal dialogs, it can be passed as an argument to the window.showModalDialog() method and access can be abstracted through a function such as this:

function getExternalOM()
{
    // For IE windows, window.external will exist but will not have any
    // methods.  <starwars>This isn't the window.external we are looking
    // for.</starwars>
    if ("foo" in window.external) {
        return window.external;
    }

    if (window.dialogArguments != null &&
        window.dialogArguments.externalOM != null) {
        return window.dialogArguments.externalOM;
    }

    return null;
}

Comments are closed.

WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Log in