-
Feb 24th, 2013, 01:38 AM
#1
Thread Starter
Lively Member
Mouse Event for detecting if mouse is hovering over URL
Okay, so I have a basic web browser project (back/forward buttons, stop/refresh, and all the necessary components). I am using the Webbrowser object provided in the toolbox. How can I have it so that when the mouse hovers over a link inside the browser, it displays the link as a string on a label on the form (I.e a status label to tell what URL the mouse is hovering over).
-
Feb 24th, 2013, 11:42 AM
#2
Re: Mouse Event for detecting if mouse is hovering over URL
Unfortunately webbrowser has no mouse events of its own so you'll have to do this on a timer, something like this ...
vb.net Code:
Private Sub Timer1_Tick(sender As System.Object, e As System.EventArgs) Handles Timer1.Tick Try Dim el = WebBrowser1.Document.GetElementFromPoint(PointToClient(Cursor.Position)) If el.TagName = "A" Then Me.Text = el.GetAttribute("href") Else Me.Text = "" End If Catch Me.Text = "" End Try End Sub
As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"
Reviews: "dunfiddlin likes his DataTables" - jmcilhinney
Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!
-
Feb 24th, 2013, 01:16 PM
#3
Re: Mouse Event for detecting if mouse is hovering over URL
WebBrowser.StatusText Property
The status text contains the URL of a hyperlink when the mouse pointer hovers over it, handle the StatusTextChanged event.
Code:
Private Sub WebBrowser1_StatusTextChanged(sender As Object, e As System.EventArgs) Handles WebBrowser1.StatusTextChanged
Label1.Text = WebBrowser1.StatusText
End Sub
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|