在选项卡式Web浏览器中打开新Windows [英] Open New Windows In Tabbed Web Browser
问题描述
我在vb.net上制作了一个带标签的webbrowser。除了一个问题外,它确实很顺利。如果我点击链接,它有时会在IE中打开。我正在使用默认的webbrowser而不是axwebbrowser,因为我的一些代码无法使用它。有没有
,所以它会在新标签中打开?
Hi, I have made a tabbed webbrowser in vb.net. It is going really well except from one problem. If I click on a link, it will sometimes open in IE. I am using the default webbrowser and not axwebbrowser as some of my code does not work with it. Is there any way so it will open in a new tab?
推荐答案
编辑:
我找到了修复!!!
添加此代码:
私人 < span style ="color:Blue"> Sub WebBrowser1_NewWindow( ByVal sender
As 对象,
ByVal e As System.ComponentModel.CancelEventArgs)
句柄 WebBrowser1.NewWindow
Dim myElement
As HtmlElement = WebBrowser1.Document.ActiveElement
&NBSP;&NBSP;&NBSP; Dim target
As String = myElement.GetAttribute(" href" )
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")
e.cancel = true
e.cancel = true
'这找到新的窗口链接,然后取消操作。
'This finds out the new window link, then cancels the action.
webbrowser1.navigate(target)
webbrowser1.navigate(target)
'告诉浏览器导航到新标签页
'That tells the browser to navigate to the new tabs URL
这篇关于在选项卡式Web浏览器中打开新Windows的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!