Opening a hyperlink in a default browser instead of MSIE.

By default, any hyperlink will open in Microsoft Internet Explorer which is not desired. So, you can use the following snippet so that the links will open in the default web browser.

private void Form1_Load(object sender, System.EventArgs e)
     var wysiwygBrowser = winFormHtmlEditor1.GetTheWebBrowser();
     wysiwygBrowser.Navigating += webBrowser1_Navigating;

     var previewBrowser = winFormHtmlEditor1.GetThePreviewWebBrowser();
     previewBrowser.Navigating += webBrowser1_Navigating;

 private void webBrowser1_Navigating(object sender, WebBrowserNavigatingEventArgs e)
     if (e.Url.ToString().StartsWith("http://", StringComparison.OrdinalIgnoreCase) || e.Url.ToString().StartsWith("https://", StringComparison.OrdinalIgnoreCase))
         //cancel the current event
         e.Cancel = true;

         //this opens the URL in the user's default browser
Last updated on May 15, 2024