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)
'you can add filters here. Sample you don't want the users to browse youtube
'so you include the keywords from below
If InStr(1, URL, ".avi") > 0 Or InStr(1, URL, ".wmv") > 0 Or InStr(1, URL, "youtube") Then
MsgBox "Can not view this page"
Cancel = True
End If
End Sub
Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
On Error Resume Next
If (pDisp Is WebBrowser1.Application) Then
Dim HTML As HTMLDocument 'Notice the changes here
Dim AHREF As HTMLAnchorElement 'and Here
Set HTML = WebBrowser1.Document 'Set the Doc to the HTML object
For Each AHREF In HTML.links 'Take note when you type '.' look at all the goodies!
'look in the AHREF object as well....
'in this case we will use 2 different parts of the AHREF object to
'filter out.. the href, and the innerText
If InStr(AHREF.href, "google") = 0 And AHREF.innerText <> "Cached" Then