|
|
Microsoft WebBrowser Control - Перехват перехода по адресу и Блокировка открытия нового окна
Private Sub objWebBrowser_BeforeNavigate2(ByVal pDisp As Object, URL As Variant, Flags As Variant, _
TargetFrameName As Variant, PostData As Variant, Headers As Variant, Cancel As Boolean)
On Error GoTo objWebBrowser_BeforeNavigate2_Err
If Me!objWebBrowser.LocationURL = "" Then Exit Sub
MsgBox "Событие BeforeNavigate2 = " & URL
Cancel = True
Application.FollowHyperlink URL
objWebBrowser_BeforeNavigate2_Bye:
Exit Sub
objWebBrowser_BeforeNavigate2_Err:
MsgBox "Ошибка " & Err.Number & vbCrLf & Err.Description & vbCrLf &
"в процедуре: objWebBrowser_BeforeNavigate2", vbCritical, "Error in module ..."
Resume objWebBrowser_BeforeNavigate2_Bye
End Sub
Private Sub objWebBrowser_NewWindow2(ppDisp As Object, Cancel As Boolean)
MsgBox "Переход в новое окно запрещён!" & vbCrLf & _
"Событие NewWindow2 = " & Me!objWebBrowser.LocationURL, vbInformation, "Запрещено!"
Cancel = True
End Sub
|
|