vb 打开网页时始终在WebBrowser1显示

2024-12-04 22:57:06
推荐回答(1个)
回答1:

如何让新窗口链接在本窗口直接打开
1.建2个WebBrowser分别为WebBrowser1、WebBrowser2
2.添加代码如下:
Private Sub WebBrowser1_NewWindow2(ppDisp As Object, Cancel As Boolean)
Set ppDisp = WebBrowser2.Object
End Sub

Private Sub WebBrowser2_BeforeNavigate2(ByVal pDisp As Object, URL As Variant, Flags As Variant, TargetFrameName As Variant, PostData As Variant, Headers As Variant, Cancel As Boolean)
Cancel = True
WebBrowser1.Navigate URL
End Sub