Private Sub mainWebBrowser_DocumentCompleted(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles mainWebBrowser.DocumentCompleted
Dim Olink As HtmlElement
Dim Elem As HtmlElementCollection = mainWebBrowser.Document.Links
'check the link that has been clicked
For Each Olink In Elem
'call the procedure to check if this is a valid link
Olink.AttachEventHandler("onclick", AddressOf LinkClicked)
Olink.AttachEventHandler("mousemove", AddressOf LinkStatus)
Next
End Sub
Private Sub LinkClicked()
Accepted = False
Dim link As HtmlElement = mainWebBrowser.Document.ActiveElement
Dim url As String = link.GetAttribute("href")
Call CheckLinkClicked(url)
'Call SearchValue()
If Accepted = True Then
mainWebBrowser.Navigate(url)
ToolStripStatusLabel2.Text = url & "(Allowed)"
Else
bCancel = True
ToolStripStatusLabel2.Text = url & "(not allowed)"
MsgBox("That is not an allowed URL" & Chr(13) & Chr(10) & "If this is wrong, then someone needs to enter this site into the allowed list!")
End If
urlTextBox.Text = mainWebBrowser.Url.ToString
End Sub
Sub LinkStatus()
Accepted = False
Dim link As HtmlElement = mainWebBrowser.Document.ActiveElement
Dim url As String = link.GetAttribute("href")
Call CheckLinkClicked(url)
'Call SearchValue()
If Accepted = True Then
ToolStripStatusLabel2.Text = url & "(Allowed)"
Else
ToolStripStatusLabel2.Text = url & "(not allowed)"
End If
End Sub