vb.net 在新的 IE11 选项卡中打开 link(而不是 window)
vb.net open link in new IE11 tab (instead of window)
我需要强制我的应用程序在 IE11 中打开几个 link(有几个按钮 - 一个按钮下有一个 link)(无论它是否设置为默认浏览器)。
我尝试了多种方法,但结果总是一样的:
Process.Start("iexplore.exe", 地址)
它非常适用于 Firefox 或 Chrome,但对于 IE - 它总是为每个 link 打开新的 window。不管IE是否已经打开。
几年前我写了类似的东西,我猜是在 IE7 上工作的......:[=14=]
导入 SHDocVw
Dim internetExplorerInstances As New ShellWindows()
Dim foundIE As Boolean = False
foundIE = False
For Each ie As InternetExplorer In internetExplorerInstances
If ie.Name = "internet explorer" Then
ie.Navigate(address, &H800)
foundIE = True
Exit For
End If
Next
If Not foundIE Then
With oPro
.StartInfo.UseShellExecute = True
.StartInfo.Arguments = address
.StartInfo.FileName = "iexplore"
.Start()
End With
End If
但是今天,在 IE 11 中它不起作用....我的意思是它仍然在新 windows 中打开 URL。
您是否有任何想法如何以编程方式强制 IE11 在新选项卡中打开 link,而不是在新 window 中?
除了一个细节外,上面的代码大体上是可以的——它应该是:
If IE.Name = "Internet Explorer" Then...
区分大小写。
最后我的代码是这样的:
Imports SHDocVw
Const openInTab As Object = &H800
Dim internetExplorerInstances As New ShellWindows()
Public Function IsProcessOpen(ByVal name As String) As Boolean
For Each clsProcess As Process In Process.GetProcesses
If clsProcess.ProcessName.Contains(name) Then
Return True
End If
Next
Return False
End Function
(...)
然后调用:
If IsProcessOpen("iexplore") Then
For Each IE As InternetExplorer In internetExplorerInstances
If IE.Name = "Internet Explorer" Then
IE.Navigate2(address, openInTab)
Exit For
End If
Next
Else
Process.Start("iexplore", address)
End If
而且有效:)
我需要强制我的应用程序在 IE11 中打开几个 link(有几个按钮 - 一个按钮下有一个 link)(无论它是否设置为默认浏览器)。
我尝试了多种方法,但结果总是一样的:
Process.Start("iexplore.exe", 地址)
它非常适用于 Firefox 或 Chrome,但对于 IE - 它总是为每个 link 打开新的 window。不管IE是否已经打开。
几年前我写了类似的东西,我猜是在 IE7 上工作的......:[=14=]
导入 SHDocVw
Dim internetExplorerInstances As New ShellWindows()
Dim foundIE As Boolean = False
foundIE = False
For Each ie As InternetExplorer In internetExplorerInstances
If ie.Name = "internet explorer" Then
ie.Navigate(address, &H800)
foundIE = True
Exit For
End If
Next
If Not foundIE Then
With oPro
.StartInfo.UseShellExecute = True
.StartInfo.Arguments = address
.StartInfo.FileName = "iexplore"
.Start()
End With
End If
但是今天,在 IE 11 中它不起作用....我的意思是它仍然在新 windows 中打开 URL。
您是否有任何想法如何以编程方式强制 IE11 在新选项卡中打开 link,而不是在新 window 中?
除了一个细节外,上面的代码大体上是可以的——它应该是:
If IE.Name = "Internet Explorer" Then...
区分大小写。
最后我的代码是这样的:
Imports SHDocVw
Const openInTab As Object = &H800
Dim internetExplorerInstances As New ShellWindows()
Public Function IsProcessOpen(ByVal name As String) As Boolean
For Each clsProcess As Process In Process.GetProcesses
If clsProcess.ProcessName.Contains(name) Then
Return True
End If
Next
Return False
End Function
(...)
然后调用:
If IsProcessOpen("iexplore") Then
For Each IE As InternetExplorer In internetExplorerInstances
If IE.Name = "Internet Explorer" Then
IE.Navigate2(address, openInTab)
Exit For
End If
Next
Else
Process.Start("iexplore", address)
End If
而且有效:)