Article ID: 815714 - View products that this article applies to.
For a Visual Basic .NET version of this article, see 311282
For a Visual Basic 6.0 version of this article, see 184876
This article describes how to use the NewWindow2 event that is triggered by the Microsoft WebBrowser control that is included with Microsoft Internet Explorer 4.0 and later. You can use this event to specify that your browser program is used whenever a new browser window is opened. This article describes this procedure for Visual C#.
The NewWindow2 EventThe NewWindow2 event occurs when a new window is created to display a resource. This event comes before a new window is created from the WebBrowser control (for example, in response to a navigation that is targeted to a new window or to a scripted window.open method).
To specify that your browser program is used whenever a new window is opened, set ppDisp equal to a new WebBrowser object that is contained in a new window that is created by your program. In this scenario, if a user chooses to open a Web page in a new window, the new window in your program is used to display the new Web page.
Additionally, set the RegisterAsBrowser property to true for the new WebBrowser control for the control to participate in window-name resolution. For example, if the window name is used elsewhere in the script, this control is used instead of a newly created one because the control checks all the existing window names before opening a new window.
Create the Project and Add CodeThe following sample directs the WebBrowser control to the following Web site:
For more information about the WebBrowser control and the methods, properties, and events that it exposes, see the WebBrowser documentation at the following (Microsoft Developer Network) MSDN Web site:
Article ID: 815714 - Last Review: July 30, 2008 - Revision: 5.1