Results 1 to 4 of 4

Thread: How to know if Navigate2 of Webbrowser control has finished?

  1. #1

    Thread Starter
    Fanatic Member alexandros's Avatar
    Join Date
    Oct 2002
    Location
    Milky Way Galaxy
    Posts
    694

    How to know if Navigate2 of Webbrowser control has finished?

    Does anybody know how to know if Navigate2 function of Webbrowser control has finished?

    I navigate to a website then navigate to a link of a frame of this website.
    The problem is that the computer does not wait until the navigating has finished.

    i read i should type something like this
    VB Code:
    1. Private Sub wbrowser_BeforeNavigate2(ByVal pDisp As Object, URL As Variant, Flags As Variant, TargetFrameName As Variant, PostData As Variant, Headers As Variant, Cancel As Boolean)
    2. hdoc_complete = False
    3. End Sub
    4.  
    5.  
    6.  
    7.  
    8. Private Sub wbrowser_DocumentComplete(ByVal pDisp As Object, URL As Variant)
    9. If (pDisp Is wbrowser.Object) Then
    10. hdoc_complete = True
    11. End If
    12.  
    13. End Sub
    14. and in the main sub
    15.  
    16. wbrowser.Navigate2 (wbrowser.Document.frames.Item(5).Document.All.tags("A").Item(3).href)
    17.     DoEvents
    18.    
    19.     Do While hdoc_complete = False
    20.         DoEvents
    21.     Loop

    the problem is that the computer halts and hdoc_complete is FALSE ALL THE TIME.

    please help because microsoft screwed it again !!!

  2. #2
    Fanatic Member TheVader's Avatar
    Join Date
    Oct 2002
    Location
    Rotterdam, the Netherlands
    Posts
    871
    I don't really know which approach you've chosen in the above example, but you could use the DocumentComplete and NavigateComplete events of the browser control. You could e.g. check if the URL is right before doing anything else. Also take a look at the Budy property of the browser control (which returns True when the browser is working, else False).
    Author for Visual Basic Web Magazine

    My articles on the Web Browser Control:
    Using the Web Browser Control & Using the DHTML Document Object Model

    The examples referenced in the articles can be found here:

  3. #3

    Thread Starter
    Fanatic Member alexandros's Avatar
    Join Date
    Oct 2002
    Location
    Milky Way Galaxy
    Posts
    694
    from what i have read the documetcomplete event
    is not reliable.
    i tried to use them but they were crap.
    instead i used a timer to wait 3 seconds for each page.
    now it works fine but it is not that good programmatically.

    i will try the budy property you told me.

    cheers
    alex

  4. #4
    Fanatic Member TheVader's Avatar
    Join Date
    Oct 2002
    Location
    Rotterdam, the Netherlands
    Posts
    871
    Ok, good luck. And sorry but it's busy, not budy, my bad...
    Author for Visual Basic Web Magazine

    My articles on the Web Browser Control:
    Using the Web Browser Control & Using the DHTML Document Object Model

    The examples referenced in the articles can be found here:

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width