Results 1 to 13 of 13

Thread: Webbrowser - Detect Page Downloaded

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2000
    Posts
    316

    Webbrowser - Detect Page Downloaded

    I need to be able to call a function when a document is completed downloading.

    I have tried this:

    Code:
    Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
    
    Call MyFunction
    
    End Sub
    But, MyFunction calls performs and operation and then calls another webpage. But, the Private Sub Document Complete seems to be getting ahead of itself and not waiting for the page to completely load.

    Is there any way I can truly wait to call that function after the page has fully loaded?
    Using VS 6 Enterprise w/ SP5 & Windows 2000 Professional

  2. #2
    Frenzied Member
    Join Date
    Mar 2001
    Location
    You are HERE •™
    Posts
    1,300
    Try something like this:

    VB Code:
    1. Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
    2.  
    3.     If (pDisp is WebBrowser1.Object) Then
    4.         If URL = "http://www.the-url-where-you-want-to-call-your-function.com"
    5.             Call MyFunction
    6.         End If
    7.     End If
    8.  
    9. End Sub

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2000
    Posts
    316
    This sorta works:

    Code:
    Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
    
       If (pDisp Is WebBrowser1.Object) Then
          Call MyFunction
       End If
    
    End Sub
    But, it doesn't appear to work with detecting a page with frames.

    Can anyone assist?
    Using VS 6 Enterprise w/ SP5 & Windows 2000 Professional

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2000
    Posts
    316
    Thanks Bloodeye, but the URL is constantly changing? Is there another way?

    And, the URL is hidden the frame of the page loading.
    Using VS 6 Enterprise w/ SP5 & Windows 2000 Professional

  5. #5
    Frenzied Member
    Join Date
    Mar 2001
    Location
    You are HERE •™
    Posts
    1,300
    If you just go with:
    VB Code:
    1. Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
    2.  
    3.    If (pDisp Is WebBrowser1.Object) Then
    4.       Call MyFunction
    5.    End If
    6.  
    7. End Sub

    This is all you need. When the condition (pDisp Is WebBrowser1.Object) is met then the web-page including all the frames within have completely loaded.

  6. #6
    Frenzied Member Skitchen8's Avatar
    Join Date
    Feb 2001
    Location
    Binghamotn, NY
    Posts
    1,943
    can't you just use the document_complete function... why do you need the other code??
    Government is another way to say better…than…you.
    It’s like ice but no pick, a murder charge that won’t stick,
    it’s like a whole other world where you can smell the food,
    but you can’t touch the silverware.
    Huh, what luck. Fascism you can vote for.
    Humph, isn’t that sweet?
    And we’re all gonna die some day, because that’s the American way
    -Stone Sour

  7. #7
    Frenzied Member Skitchen8's Avatar
    Join Date
    Feb 2001
    Location
    Binghamotn, NY
    Posts
    1,943
    found it

    Private Sub WebBrowser1_DownloadComplete()

    End Sub
    Government is another way to say better…than…you.
    It’s like ice but no pick, a murder charge that won’t stick,
    it’s like a whole other world where you can smell the food,
    but you can’t touch the silverware.
    Huh, what luck. Fascism you can vote for.
    Humph, isn’t that sweet?
    And we’re all gonna die some day, because that’s the American way
    -Stone Sour

  8. #8

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2000
    Posts
    316
    No, that's not it.

    That will crash the program. That Sub isn't intended to detect when a page in the frame is finished loading.
    Using VS 6 Enterprise w/ SP5 & Windows 2000 Professional

  9. #9
    Frenzied Member Skitchen8's Avatar
    Join Date
    Feb 2001
    Location
    Binghamotn, NY
    Posts
    1,943
    ok... sry haven't used the browser control in awhile, im working on making my own
    Government is another way to say better…than…you.
    It’s like ice but no pick, a murder charge that won’t stick,
    it’s like a whole other world where you can smell the food,
    but you can’t touch the silverware.
    Huh, what luck. Fascism you can vote for.
    Humph, isn’t that sweet?
    And we’re all gonna die some day, because that’s the American way
    -Stone Sour

  10. #10
    Frenzied Member
    Join Date
    Mar 2001
    Location
    You are HERE •™
    Posts
    1,300
    bedowin -

    What is it your trying to do with your function?

  11. #11

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2000
    Posts
    316
    The Function takes the HTML source of the page loaded and parses out necessary information.

    My problem is that sometimes the server doesn't return the page in a timely manner, so that even putting in a wait event for 10 seconds might not be sufficient to make sure the framed page is loaded completely.

    I just want some assurance that it is loaded, and am wondering if there is a way to accomplish this.
    Using VS 6 Enterprise w/ SP5 & Windows 2000 Professional

  12. #12
    Fanatic Member nabeels786's Avatar
    Join Date
    Jul 2001
    Location
    New York
    Posts
    919
    my prog had to do the same thing...Bloodeyes method works..
    Visit www.fragblast.com
    Gaming, forums, and a online RPG/Battle system




    (__Flagg) DOT NET? is this a Hindi Dating service?

  13. #13

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2000
    Posts
    316
    yes.. his method would work, if I knew the ever-changing URL.

    In this case I do not.

    However, I have just solved this problem I believe.

    What I did was do a search for footer text that appears on each loaded page. If it appears, then my parsing code runs, if not then it attempts to reload the page complete and will not run the parsing code until it finds the footer text.

    woohoo!
    Using VS 6 Enterprise w/ SP5 & Windows 2000 Professional

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