Javascript Window.Opener Object Null on .NET WebBrowser Control New Window -


OK, I have a pop up in the .Net Framework's webcure control that I capture with the Newwanda event handler I am

  Web browser w = new webbrowser (); SHDocVw.WebBrowser_V1 Web = (SHDocVw.WebBrowser_V1) w.ActiveXInstance; Web.NewWindow + = New SHDocVw.DWebBrowserEvents_NewWindowEventHandler (web_NewWindow);  

The new popup webbrosor is in a new form with a new example of control

  zero web_NewWindow (string url, int flag, string targetframeName, ref object PostData, String Header, Ref Bull Processed) {Processed = true; Web browser w2 = new webbrowser (); Form popup = new form (); PopUp.Controls.Clear (); PopUp.Controls.Add (W2); W2.Dock = DocStyle fill; PopUp.Show (); W2.Navigate (url); W2.DocumentCompleted + = New WebBrowserDocumentCompletedEventHandler (w2_DocumentCompleted); }  

My problem is that the window.Opera object is zero in the process

The user uses that field to return that area to the original window and the form But fills some values.

Is there any window to pass? Opener object next to a web browser control? It seems impossible that it will work but I have to try.

Thanks

Yes, there is a way to pass the window. Obner object next to a web browser control
See the code below for details

  Public category WebBrowserTest {Private webbrowser _wParent; // Navigation Point Navigating Public Zero (string url) {_wParent = new WebBrowser (); SHDocVw.WebBrowser_V1 v1 = (SHDocVw.WebBrowser_V1) w.ActiveXInstance; V1.NewWindow + = v1_NewWindow; } Private Zero v1_NewWindow (String URL, Int Flag, String TargetFrameName, Reef Object PostData, String Header, Ref Bull Processed) {// Tell, we will open new pages by ourselves Process = true; // WebBrowser page open by itself w2 = new WebBrowser (); W2.Navigate (url); // w2.DocumentCompleted + w2_DocumentCompleted if waiting for the document will be loaded to some magic stuff; } // Set Opener // popup window for popup window after document was private zero zero loaded w2_Document (Object Sender, EventArgs e) {WebBrowser Popup = (WebBrowser) Sender; SetOpener (_wparent, popup); } // My most preferred method :) / / That hack is actually included, we are talking about Private Zero SetOpener (Webbrozer Opener, Web Browser Popup) {HTMLWindow htmlPopup = popup.Document.Window; HTMLWindow htmlOpener = opener.Document.Window; // can let the dark magic began / In fact, WebBrowser control net wrapper around IE COM interfaces // We reached a little closer through the terms of the // "mshtml.IHTMLWindow2" field through reflection FieldInfo fi = Html popup gettype () GetField ("HTMLWindow2", Binding Flags.Instance | BindingFlags.NonPublic); Mshtml.IHTMLWindow2HTML popup2 = (mshtml.IHTMLWindow2) fi.GetValue (html popup); Mshtml.IHTMLWindow2HTMLOpener2 = (mshtml.IHTMLWindow2) Flightgate Value (HTML Opener); // Opener is set here htmlPopup2.window.opener = htmlOpener2.window.self; }}  

PS I think the chances are that it is still real, = too little, but, anyway)


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -