Raised when a new window is to be created. Extends DWebBrowserEvents2::NewWindow2 with additional information about the new window.
void NewWindow3( IDispatch **ppDisp, VARIANT_BOOL *Cancel, DWORD dwFlags, BSTR bstrUrlContext, BSTR bstrUrl );
- [in, out] An interface pointer that, optionally, receives the IDispatch interface pointer of a new WebBrowser object or an InternetExplorer object.
- [in, out] A VARIANT_BOOL value that determines whether the current navigation should be canceled.
- Cancel the navigation.
- Do not cancel the navigation.
- [in] The flags from the NWMF enumeration that pertain to the new window.
- [in] The URL of the page that is opening the new window.
- [in] The URL that is opened in the new window.
No return value.
The DISPID for this event is defined in exdispid.h. Use this value to identify the event handler when implementing IDispatch::Invoke.
NewWindow3 is available only in Windows XP Service Pack 2 (SP2) or later. This event fires instead of NewWindow2.
The NewWindow3 event is not raised when the user selects the New Window command on the File menu in Windows Internet Explorer. Instead, this event precedes the creation of a new window in the WebBrowser in response to a navigation targeted to a new window, or from script using the IHTMLWindow2::open method. The event is raised during the following actions:
- The user clicks a link while pressing the SHIFT or CTRL key.
- The user right-clicks a link and selects Open in New Window or Open in New Tab .
- There is a targeted navigation to a frame name that does not yet exist, or
- Script invokes window.open.
- A browser application calls Navigate or Navigate2 with the navOpenInNewWindow flag.
The application that processes this notification can respond in one of three ways:
- Create a new, hidden, non-navigated WebBrowser object or InternetExplorer object that is returned in ppDisp. On return, the object that fired this event configures and navigates (including a BeforeNavigate2 event) the new object to the target location.
- Cancel the navigation by setting Cancel to VARIANT_TRUE.
- Do nothing and do not set ppDisp to any value. This will cause the object that fired the event to create a new InternetExplorer object as a separate (non-hosted) process to handle the navigation.Note The DWebBrowserEvents2::NewWindow3 event is only fired when a new instance of Internet Explorer is about to be created. Calling IHTMLWindow2::showModalDialog or IHTMLWindow3::showModelessDialog does not trigger an event because they are not new instances of Internet Explorer. They are implemented as MSHTML host windows, which allows them to render and display HTML content but not hyperlinks between documents.