vb编程,窗口一放一个WebBrowser,点击这页面中内容,窗口二的WebBrowser显示刚点

2025-01-18 21:07:55
推荐回答(2个)
回答1:

窗口一代码:

Dim WithEvents Web_V1 As SHDocVwCtl.WebBrowser_V1

Private Sub Form_Load()
Set Web_V1 = WebBrowser1.Object
WebBrowser1.Silent = True
WebBrowser1.Navigate "网址"
End Sub

Private Sub Web_V1_NewWindow(ByVal URL As String, ByVal Flags As Long, ByVal TargetFrameName As String, PostData As Variant, ByVal Headers As String, Processed As Boolean)
Processed = True
Form2.WebBrowser1.Navigate URL
Form2.Show
End Sub

回答2:

Dim URL1

Private Sub Form_Load()
WebBrowser1.Navigate "www.baidu.com"
Form2.Show
End Sub

Private Sub WebBrowser1_BeforeNavigate2(ByVal pDisp As Object, URL As Variant, Flags As Variant, TargetFrameName As Variant, PostData As Variant, Headers As Variant, Cancel As Boolean)
URL1 = URL
End Sub

Private Sub WebBrowser1_NewWindow2(ppDisp As Object, Cancel As Boolean)
Cancel = True
Form2.WebBrowser1.Navigate URL1
End Sub