【问题标题】:Is there a way to tell the Wiinforms WebBrowser control to use the current browser to open a hyperlink in?有没有办法告诉 Wiinforms WebBrowser 控件使用当前浏览器打开超链接?
【发布时间】:2012-06-19 22:18:40
【问题描述】:

我有一个带有 Web 浏览器控件的 winforms 应用程序。我想知道是否有办法告诉浏览器控件在当前活动的浏览器中打开一个 URL,不管它是否是默认浏览器。我的直觉是这根本不可行,因为此控件使用的是用户定义的操作系统的默认浏览器。

【问题讨论】:

标签: winforms browser


【解决方案1】:

使用:

System.Diagnostics.Process.Start()


或者试试这个:

Private Sub WebBrowser1_NewWindow(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles WebBrowser1.NewWindow
    Dim myElement As HtmlElement = WebBrowser1.Document.ActiveElement
    Dim target As String = myElement.GetAttribute("href")
    Dim newInstance As New Form1
    newInstance.Show()
    newInstance.WebBrowser1.Navigate(target)
    e.Cancel = True
End Sub

【讨论】:

  • 如果我为活动浏览器而不是 Web 浏览器控件提交表单,我将如何使用它?
  • Dim target As String = myElement.GetAttribute("href") --------- System.Diagnostics.Process.Start(target) --------- e .Cancel = True
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-08-15
  • 2013-08-04
  • 1970-01-01
  • 1970-01-01
  • 2012-06-11
  • 1970-01-01
相关资源
最近更新 更多