先用NewWindow事件捕获新窗口要打开的URL,然后把它设置为自定义新窗口的URL,并打开自定义新窗口,接着取消用系统默认浏览器打开新窗口的动作。
示例代码:
Private Sub WebBrowser1_NewWindow( ByVal sender As Object , ByVal e As System.ComponentModel.CancelEventArgs) Handles WebBrowser1.NewWindow
Dim NewURL As String = CType (sender, WebBrowser).StatusText
Dim frmNew As New Form1
frmNew.WebBrowser1.Navigate(NewURL)
' 或者是frmNew.WebBrowser1.Url = New Uri(NewURL)
frmNew.Show()
e.Cancel = True
End Sub
示例代码:
Private Sub WebBrowser1_NewWindow( ByVal sender As Object , ByVal e As System.ComponentModel.CancelEventArgs) Handles WebBrowser1.NewWindow
Dim NewURL As String = CType (sender, WebBrowser).StatusText
Dim frmNew As New Form1
frmNew.WebBrowser1.Navigate(NewURL)
' 或者是frmNew.WebBrowser1.Url = New Uri(NewURL)
frmNew.Show()
e.Cancel = True
End Sub