0

I'm using a wpf webBrowser control. The loadComplete event is not firing. I looked at the page I'm navigating to and I see that it has some js errors. I'm assuming this is the reason. Can anybody figure out a workaround? I need the event to fire.

Thanks

Mike Turner
  • 471
  • 1
  • 7
  • 22
  • The WebBrowser control defaults to IE 7 rendering mode. You may need to use a proper DOCTYPE at the top of the HTML or update the registry with IE 11 rendering mode for your .exe. See my answer here: http://stackoverflow.com/questions/41144328/integration-of-vimeos-video-in-wpf/41146080#41146080 – jschroedl Mar 21 '17 at 14:00
  • 1
    I already edited the registry value here for other functionality that I needed... but didn't prevent this. I can't change the DOCTYPE, its navigating to a URL that I'm not in control of. Even when I go to the URL in chrome, in developer tools, I see some js errors – Mike Turner Mar 21 '17 at 14:13
  • hmm, I looked at my code and I'm handling the Navigated event, not loadComplete so I may be out of ideas. I do have code similar to the accepted answer here to suppress script errors but it may only hide the popup messages we can see: http://stackoverflow.com/questions/6138199/wpf-webbrowser-control-how-to-supress-script-errors – jschroedl Mar 22 '17 at 11:54
  • I set my browser to silent using this: http://stackoverflow.com/questions/17697023/ie10-how-to-prevent-your-current-security-settings-do-not-allow-this-file-to/18269105#18269105 so i dont get any error popups – Mike Turner Mar 22 '17 at 15:36

1 Answers1

0

This is what was causing my issue:

A while ago, I added this code to prevent security file message (see IE10 - how to prevent "Your current security settings do not allow this file to be downloaded" popup from appearing?) and this is what prevented the event from firing

this.WB.Loaded += (s, e) =>
            {
                // get the underlying WebBrowser ActiveX object;
                // this code depends on SHDocVw.dll COM interop assembly,
                // generate SHDocVw.dll: "tlbimp.exe ieframe.dll",
                // and add as a reference to the project

                var activeX = this.WB.GetType().InvokeMember("ActiveXInstance",
                    BindingFlags.GetProperty | BindingFlags.Instance | BindingFlags.NonPublic,
                    null, this.WB, new object[] { }) as SHDocVw.WebBrowser;

                // now we can handle previously inaccessible WB events 
                activeX.FileDownload += activeX_FileDownload;
            };
Community
  • 1
  • 1
Mike Turner
  • 471
  • 1
  • 7
  • 22