I think the title covers it all. I use the control to display some basic HTML with some markups and there are maybe also links in there. What I want to do, is to force clicking on any link to get this link opened in a new IE window instead of navigating to that page in the control itself.
Any idea?
You can handle the Navigating event, set the Cancel property of WebBrowserNavigatingEventArgs to true, and use Process.Start to open the URL in IE.
Something like this:
private void webBrowser1_Navigating(object sender, WebBrowserNavigatingEventArgs e)
{
// prevents WebBrowser to navigate
if (e.Url.Host.Length > 0) // Otherwise the default about:blank when you init the control doesn't work
{
e.Cancel = true;
// Open the URL in an IE window
System.Diagnostics.Process process = new System.Diagnostics.Process();
process.StartInfo.FileName = e.Url.ToString();
process.Start();
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With