AttachEventHandler issues

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Apr 2008
Posts: 114
Reputation: ninjaimp is an unknown quantity at this point 
Solved Threads: 6
ninjaimp ninjaimp is offline Offline
Junior Poster

AttachEventHandler issues

 
0
  #1
Nov 21st, 2008
i have a web browser control which i have added a status strip.

I can get the status strip to display the clicked link fine but i would like it to display the link target when the mouse is hover over the link but i cannot get it to work!

My code is below - any help is greatly appreciated!

  1. Private Sub mainWebBrowser_DocumentCompleted(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles mainWebBrowser.DocumentCompleted
  2.  
  3.  
  4.  
  5. Dim Olink As HtmlElement
  6. Dim Elem As HtmlElementCollection = mainWebBrowser.Document.Links
  7.  
  8. 'check the link that has been clicked
  9. For Each Olink In Elem
  10. 'call the procedure to check if this is a valid link
  11. Olink.AttachEventHandler("onclick", AddressOf LinkClicked)
  12. Olink.AttachEventHandler("mousemove", AddressOf LinkStatus)
  13. Next
  14.  
  15. End Sub
  16.  
  17.  
  18.  
  19. Private Sub LinkClicked()
  20.  
  21. Accepted = False
  22.  
  23. Dim link As HtmlElement = mainWebBrowser.Document.ActiveElement
  24. Dim url As String = link.GetAttribute("href")
  25.  
  26. Call CheckLinkClicked(url)
  27.  
  28. 'Call SearchValue()
  29.  
  30. If Accepted = True Then
  31. mainWebBrowser.Navigate(url)
  32. ToolStripStatusLabel2.Text = url & "(Allowed)"
  33. Else
  34. bCancel = True
  35. ToolStripStatusLabel2.Text = url & "(not allowed)"
  36. 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!")
  37. End If
  38.  
  39. urlTextBox.Text = mainWebBrowser.Url.ToString
  40.  
  41. End Sub
  42.  
  43.  
  44. Sub LinkStatus()
  45.  
  46. Accepted = False
  47.  
  48. Dim link As HtmlElement = mainWebBrowser.Document.ActiveElement
  49. Dim url As String = link.GetAttribute("href")
  50.  
  51. Call CheckLinkClicked(url)
  52.  
  53. 'Call SearchValue()
  54.  
  55. If Accepted = True Then
  56.  
  57. ToolStripStatusLabel2.Text = url & "(Allowed)"
  58. Else
  59.  
  60. ToolStripStatusLabel2.Text = url & "(not allowed)"
  61.  
  62. End If
  63. End Sub
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC