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

前端 未结 6 1497
轮回少年
轮回少年 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

    The easiest way to do this would be to intercept the Navigating event.

    public void webBrowser1_Navigating(object sender, WebBrowserNavigatingEventArgs e)
    {
        //cancel the current event
        e.Cancel = true;
    
        //this opens the URL in the user's default browser
        Process.Start(e.Url.ToString());
    }
    

提交回复
热议问题