I currently am having a problem having a new window open when a link is clinked in my webbrowser, I cannot use webbrowser.Navigating because there are several navigations already occurring before a user can get to the link to open the new window. I've already looked at vb.net Detect if a link is clicked in Webbrowser control but that didn't help very much. Is there a way to detect a linkclick in a webbrowser? I'm at a loss right now an will appreciate any help.
Asked
Active
Viewed 1,697 times
2 Answers
4
I was able to figure out how to do it, the code is below for anyone that has a similar problem.
Private Sub webMailNavigating(sender As Object, e As WebBrowserNavigatingEventArgs) Handles webMail.Navigating
' opens link in new tab if it isn't blank and will not open emails in a new tab.
Try
If Not e.Url.ToString.Contains("emailUrl") And Not e.Url.ToString.Contains("about:blank") Then
e.Cancel = True
Process.Start(e.Url.ToString)
Else
End If
Catch
End Try
End Sub

jdwee
- 573
- 1
- 5
- 15
1
I would try this link, which in turn was linked from this other post. Both of which are using C#, however, you can convert it here if it fits your needs.
Essentially adding an event to the WebBrowser Document.
However, if you do this, it can be fussy. At times it can trigger twice if not coded perfectly.
-
1Thank you, you were very helpful, but not quite the answer I was looking for, I will post my answer for others to see shortly – jdwee Feb 12 '17 at 18:31
-
@jdwee You're welcome, and now i see what you'd done in your answer post and understand what you initially going for :) Glad you figured it out – Sir Kamui Feb 12 '17 at 19:06