如下代码:
Dim WithEvents Web_V1 As SHDocVwCtl.WebBrowser_V1
Private Sub Form_Load()
Set Web_V1 = WebBrowser1.Object
WebBrowser1.Navigate App.Path & "/login.htm"
' WebBrowser1.Navigate2 "http://www.microsoft.com/"
End Sub
Private Sub WebBrowser1_NewWindow2(ppDisp As Object, Cancel As Boolean)
' Set ppDisp = WebBrowser2.Application
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
WebBrowser2.Navigate URL
End Sub
以上方法,可以将代码拦截新窗体地址!