Saturday 15 May 2010

C# WPF WebBrowser control, JavaScript writeln function not working after intercepting newWindow2 -


I have the WPF WebBrowser control User logs in to a website using this and the session is created. When people click on links that create popups, a new browser is launched (and the session is lost) so that they can be forced to re-certify.

I have a new window on new handler by specifying a new handler about 2 Event:

  Guid SID_SWebBrowserApp = new Good ( "0002DF05-0000-0000-C000-000000000046 "); IServiceProvider serviceProvider = (IServiceProvider) webBrowser.Documentation; Guid serviceGuid = SID_SWebBrowserApp; Guid iid = typeof (SHDocVw.IWebBrowser2). Dog; SHDocVw.IWebBrowser2 myWebBrowser2 = (SHDocVw.IWebBrowser2) serviceProvider.QueryService (referee serviceguide, ref IID); SHDocVw.DWebBrowserEvents2_Event wbEvents2 = (SHDocVw.DWebBrowserEvents2_Event) myWebBrowser2; WbEvents2.NewWindow2 + = New SHDocVw.DWebBrowserEvents2_NewWindow2EventHandler (wbEvents2_NewWindow2);   

The event handler code is as follows:

  public void wbEvents2_NewWindow2 (Ref object ppDisp, ref bool Cancel) {popUpWindow = new Window1 (); PopUpWindow.Show (); Popup window.webbroser Navigate (new Uri ("about: empty")); Guid SID_SWebBrowserApp = New Guid ("0002DF05-0000-0000-C000-000000000046"); IServiceProvider serviceProvider = (IServiceProvider) popUpWindow.webBrowser.Document; Guid serviceGuid = SID_SWebBrowserApp; Guid iid = typeof (SHDocVw.IWebBrowser2). Dog; SHDocVw.IWebBrowser2 myWebBrowser2 = (SHDocVw.IWebBrowser2) serviceProvider.QueryService (Ref Sewaguid referee IID); PpDisp = myWebBrowser2 Application; }   

Everything works well until some JavaScript snippets are included. For example, if a link that creates popup digits in the JavaScript function in this function:

  & lt; A href = "javascript: someFunction ('some parameters', 'some parameters')" & gt; Link something here & lt; / A & gt;   

and open window to window inside the function, then the value is set equal to a HTML document and try to write the document, never written document Vebbraujr Goes control For example:

  var somevar = window.open (a "????", "parameter", "parameter" ??); War someDocument = someVar.document; SomeDocument.writeln ("This webbrowser never ends in the source of the page loaded in control"); If I comment on my code which prevents the new winding event and allows a new browser to launch and my user to re-sign - popup load as expected (Javascript writes data to a written work document).  

I was hoping someone could explain to me why a document is not being written in JavaScript, which is displayed in the WPF WebBrowser control, and / or suggests a way to do it is .

Have you tried a different GUID for the browser?

No comments:

Post a Comment