I am currently building a webbrowser that only loads one page, but I don't want the user to be able to navigate away by clicking advertisement links, as I don't want them to be able to surf the net, clicking links could eventually lead them back to Google to search for what they like if they are clever enough!
Any ide开发者_开发知识库as?
When the page is done loading, intercept the links :
Dim olink As HtmlElement
Dim olinks As HtmlElementCollection = WB1.Document.Links
For Each olink In olinks
olink.AttachEventHandler("onclick", AddressOf LinkClicked)
Next
Then add a function :
Private Sub LinkClicked(ByVal sender As Object, ByVal e As EventArgs)
If txtAddress.Enabled = True Then
Dim link As HtmlElement = WB1.Document.ActiveElement
Dim url As String = link.GetAttribute("href")
MsgBox("Link Clicked: " & link.InnerText & vbCrLf & "Destination: " & url)
WB1.Navigate(url, False)
End If
End Sub
Sounds like more of a sysadmin issue, to me.
I'm not familiar with any of the proper software. but if you set up the OS so that it will only be allowed to access webpages on a "whitelist", then there will be no need to write a custom web browser.
If you have a browser component in you project, you should add an event listener for your browser URL, if it changed, redirect to your desired page.
精彩评论