Joe
Joe

Reputation: 1057

vb.net WebBrowser links to Default Web Browser

is there a way to detect a person clicking a link inside WebBrowser1, and then i can do

Process.Start(TheURL)

And then return the action as false so it doesn't click the link in the webbrowser object and just the process.

Upvotes: 0

Views: 2819

Answers (1)

Chris Barlow
Chris Barlow

Reputation: 3314

Here ya go:

private void WebBrowser_Navigating(object sender, WebBrowserNavigatingEventArgs e)
  {  
        e.Cancel = true; // Cancel the event to avoid default behavior
        System.Diagnostics.Process.Start(e.Url.ToString()); // Open the link in the default browser
  }

EDIT: Meh, I had a few minutes. Here ya go again:

Private Sub WebBrowser1_Navigating(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserNavigatingEventArgs) Handles WebBrowser1.Navigating
  e.Cancel = True 'Cancel the event to avoid default behavior
  System.Diagnostics.Process.Start(e.Url.ToString()) 'Open the link in the default browser
End Sub

Upvotes: 1

Related Questions