![]() ![]() Otherwise you can just put some code in that event handler, get the URL that is opened in the new window, use ShellExecute to open it with default browser and cancel the NewWindow navigation itself. Thoughts of workarounds: The IE-based WebBrowser actually exposes a NewWindow3 event on its COM interface, unfortunately, the WPF WebBrowser control doesn't implement this event. Another example is, if IE is currently the default browser, and you are working in another browser, when that browser encounters target="_blank", will it use IE (the default browser) to open it? Very unlikely. When the WebBrower control opens a URL in a new window, it is an internal operation (so the cookies can be shared with the new window), it doesn't go through the Shell so it won't and shouldn't use the default browser to open the URL. The problem is, the so called "default browser setting" is defined in Shell, not in the IE browser. Hi, How do I tell the WebBrowser control to respect the default browser settings? I don't think there is currently an easy way. The CodeFx Project My Blog (in Simplified Chinese) If you have any feedback, please tell us. ![]() Regards, Jie MSDN Subscriber Support in Forum If you have any feedback on our support, please contact remember to mark the replies as answers if they help and unmark them if they provide no help. Please let me know if that works for you. I tested it with FF as the default browser. ![]() MessageBox.Show(wex.Message, this.Title, MessageBoxButton.OK, MessageBoxImage.Error) ProcessStartInfo psi = new ProcessStartInfo() Private void webBrowser_NewWindow3(ref object ppDisp, ref bool Cancel, uint dwFlags, string bstrUrlContext, string bstrUrl) ((SHDocVw.DWebBrowserEvents2_Event)webBrowser.ActiveXInstance).NewWindow3 += Private void Window_Loaded(object sender, RoutedEventArgs e) Then with the following code, it does exactly what you want: using System Hi, I came out a relatively simple solution and made a sample based on it: Basically I'm hosting a WinForm version of WebBrowser control: Īnd add a reference to the SHDocVw (Microsoft Internet Controls). ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |