Intercepting Javascript's windows.open command from embedded webbrowser

From: Mike (anonymous_at_discussions.microsoft.com)
Date: 04/21/04


Date: Wed, 21 Apr 2004 13:36:05 -0700

Hi! I have a WinForms application with embedded browser control. I am trying to intercept javascript's window.open() command and instead open a new form that also contains the webbrowser control. I have the following code:

private void webMain_NewWindow(PRS.WebBrowser sender, AxSHDocVw.DWebBrowserEvents2_NewWindow2Event e)
{
        //MessageBox.Show("webMain_NewWindow");
        try
        {

                e.cancel = true; //cancel new ie window

        
                PRSBaseForm someForm = new PRSBaseForm(); // form with embedded webbrowser control

                someForm.Text = String.Empty; // clear the title
                someForm.webMain.RegisterAsBrowser = true;
        

                e.ppDisp = someForm.webMain;

                someForm.Visible = true;

                                // HOW DO I GET THE URL OF THE CHILD WINDOW???
                //someForm.webMain.Navigate("http://www.someurl.com";);

                someForm.Text = someForm.webMain.document.title;
        }
        catch{}
}

Question: How do I get the url of the child window? What do I put as a parameter of the .Navigate method? Is there a better way.

Any help is greatly appreciated.
Thank you in advance,

--Mike