Webbrowser control's link and image info not provided

  • Thread starter Thread starter kimiraikkonen
  • Start date Start date
K

kimiraikkonen

Hi,
Assuming "webbrowser1.document.links.count" returns 28 items for this
array and when i want to display an array item by
"Msgbox(webbrowser1.document.links.item(1).name)" doesn't return an
array item as string. Just blank entry. Tried on Yahoo and Google with
same result.

Also webbrowser1.document.images.item(x) doesn't return a string
referring a image name/url.
x = any array index

How can i display webbrowser1.document.links or images array items as
strings? Nothing is displayed exceot only blank entry.
 
How can i display webbrowser1.document.links or images array items as
strings? Nothing is displayed exceot only blank entry.

This might help you:

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

WebBrowser1.Navigate("http://www.yahoo.com")

End Sub

Private Sub WebBrowser1_DocumentCompleted(ByVal sender As Object, ByVal
e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles
WebBrowser1.DocumentCompleted

For Each temp As HtmlElement In WebBrowser1.Document.Links
MsgBox("Text: " & temp.InnerText & vbCrLf & " Address: " &
temp.GetAttribute("href"))
Next

For Each temp As HtmlElement In WebBrowser1.Document.Images
MsgBox("Image: " & temp.GetAttribute("src"))
Next

End Sub

-Teemu
 
This might help you:

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

WebBrowser1.Navigate("http://www.yahoo.com")

End Sub

Private Sub WebBrowser1_DocumentCompleted(ByVal sender As Object, ByVal
e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles
WebBrowser1.DocumentCompleted

For Each temp As HtmlElement In WebBrowser1.Document.Links
MsgBox("Text: " & temp.InnerText & vbCrLf & " Address: " &
temp.GetAttribute("href"))
Next

For Each temp As HtmlElement In WebBrowser1.Document.Images
MsgBox("Image: " & temp.GetAttribute("src"))
Next

End Sub

-Teemu

Thanks Teemu, that was very useful.
 
Back
Top