How to open a link in webBrowser control in external browser?

前端 未结 6 1458
轮回少年
轮回少年 2020-12-15 19:39

I have a textBox and a webBrowser control in my Windows Forms application. Whenever a user enters a HTML code in textBox, the webBrowser control shows its compiled form. The

6条回答
  •  有刺的猬
    2020-12-15 19:47

    Process.Start will open the URL in the default browser, and then you just tell the WebBrowser control to cancel navigation.

    private void webBrowser1_Navigating(object sender, WebBrowserNavigatingEventArgs e)
    {
        Process.Start(e.Url.ToString());
    
        e.Cancel = true;
    }
    

    I just created a sample app to test it - it worked.

提交回复
热议问题