NewWindow3 Event

Raised when a new window is to be created. Extends NewWindow2 with additional information about the new window.

Syntax

  Private Sub object_NewWindow3( _
  ByRef ppDisp As Object, _
  ByRef Cancel As Boolean, _
  ByVal dwFlags As Long, _
  ByVal bstrUrlContext As String, _
  ByVal bstrUrl As String)

Parameters

  • object
    Object expression that resolves to the objects in the Applies To list.
  • ppDisp
    Object expression that, optionally, receives a new, hidden WebBrowser or InternetExplorer object with no URL loaded.

  • Cancel
    A Boolean value that determines whether the current navigation should be canceled.

    • true
      Cancel the navigation.
    • false
      Do not cancel the navigation.
  • dwFlags
    The flags from the NWMF enumeration that pertain to the new window.

  • bstrUrlContext
    The URL of the page that is opening the new window.

  • bstrUrl
    The URL that is opened in the new window.

Error Codes

No return value.

Remarks

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 window.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 _blank.
  • 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 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 NewWindow3 event is only fired when a new instance of Internet Explorer is about to be created. Calling showModalDialog or 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.

Applies To

InternetExplorer, WebBrowser

See Also

NavigateComplete2, NewWindow2