Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
 
 
 
500MB 27GB Web Hosting - $9.95/Month
 
 
 
 
 
Old Pages
 
Old Index
Site Map
What's New
 
Books
How To
Tips & Tricks
Tutorials
Stories
Performance
Essays
Links
Q & A
New in VB6
Free Stuff
Pictures
 
 
 
TitleRead the links on a Web page
KeywordsWeb, URL, link, WebBrowser
CategoriesControls
 
Use the WebBrowser control's Navigate method to load a Web page. When the document finishes loading, loop through the WebBrowser1.Document.links collection to examine the link objects.

Note that this program sets a reference to the Microsoft HTML Object Library.

 
Private Sub cmdLoad_Click()
    txtLinks.Text = ""
    Screen.MousePointer = vbHourglass
    DoEvents

    WebBrowser1.Navigate txtURL

    ' The rest happens in WebBrowser1_DocumentComplete.
End Sub

Private Sub WebBrowser1_DownloadComplete()
Dim doc As HTMLDocument
Dim a_link As HTMLAnchorElement
Dim txt As String

    ' List the links.
    On Error Resume Next
    Set doc = WebBrowser1.Document
    For Each a_link In doc.links
        txt = txt & a_link.href & vbCrLf
    Next a_link
    txtLinks.Text = txt

    Screen.MousePointer = vbDefault

End Sub
 
 
Copyright © 1997-2003 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated