Results 1 to 21 of 21

Thread: Web Browser complete

  1. #1

    Thread Starter
    Addicted Member VBGangsta's Avatar
    Join Date
    Aug 2003
    Location
    New York
    Posts
    219

    Web Browser complete

    how whould i initate a set a events after the web broswer is done loading a page. The page has to load completly before the events happen. How whould i do this.
    -Rob

  2. #2
    Frenzied Member dynamic_sysop's Avatar
    Join Date
    Jun 2003
    Location
    Ashby, Leicestershire.
    Posts
    1,142
    have you not tried NavigateComplete2 then? or is it missing something / triggering before the page has finished loading?
    VB Code:
    1. [Color=Blue]Private[/COLOR] [Color=Blue]Sub[/COLOR] AxWebBrowser1_NavigateComplete2([Color=Blue]ByVal[/COLOR] sender [Color=Blue]As[/COLOR] [Color=Blue]Object[/COLOR], [Color=Blue]ByVal[/COLOR] e [Color=Blue]As[/COLOR] AxSHDocVw.DWebBrowserEvents2_NavigateComplete2Event) [Color=Blue]Handles[/COLOR] AxWebBrowser1.NavigateComplete2
    2.         [Color=Green]'///[/COLOR] [Color=Green]use[/COLOR] [Color=Green]the[/COLOR] [Color=Green]NavigateComplete2[/COLOR] [Color=Green]Sub[/COLOR] [Color=Green]to[/COLOR] [Color=Green]handle[/COLOR] [Color=Green]events[/COLOR] [Color=Green]for[/COLOR] [Color=Green]a[/COLOR] [Color=Green]browser[/COLOR] [Color=Green]when[/COLOR] [Color=Green]it's[/COLOR] [Color=Green]completed[/COLOR] [Color=Green]loading.
    3. [/COLOR]    [Color=Blue]End[/COLOR] [Color=Blue]Sub[/COLOR]
    hope thats the one your after.
    ~
    if a post is resolved, please mark it as [Resolved]
    protected string get_Signature(){return Censored;}
    [vbcode][php] please use code tags when posting any code [/php][/vbcode]

  3. #3

    Thread Starter
    Addicted Member VBGangsta's Avatar
    Join Date
    Aug 2003
    Location
    New York
    Posts
    219
    The events that I put in the private sub you posted happens before the page even starts to load.
    -Rob

  4. #4
    Frenzied Member dynamic_sysop's Avatar
    Join Date
    Jun 2003
    Location
    Ashby, Leicestershire.
    Posts
    1,142
    well thats the sub that triggers upon a webpage being loaded, maybe if you specified the url within that sub and only carry out your code if it's navigated to that page it would work. like...
    VB Code:
    1. [COLOR=blue]If[/COLOR] AxWebBrowser1.LocationUrl = " Site name here " [COLOR=blue]Then[/COLOR]
    2.     [COLOR=green]'///carry out your code here.[/COLOR]
    3. [COLOR=blue]Else[/COLOR]
    4.     [COLOR=green]'/// Do nothing.[/COLOR]
    5. [COLOR=blue]End If[/COLOR]
    ~
    if a post is resolved, please mark it as [Resolved]
    protected string get_Signature(){return Censored;}
    [vbcode][php] please use code tags when posting any code [/php][/vbcode]

  5. #5

    Thread Starter
    Addicted Member VBGangsta's Avatar
    Join Date
    Aug 2003
    Location
    New York
    Posts
    219
    I Still run into the problem of not KNowing how long it takes a page to load on someone elses computer. Theres got to be a way to make navigate2 work here is my code:

    VB Code:
    1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    2.         name12 = TextBox1.Text
    3.         url = "http://www.outwar.com/playersearch.php?search=" & name12 & "&submit=Search"
    4.         Web1.Navigate(url)
    5.         Label17.Text = name12
    6.     End Sub
    7.     Private Sub web1_NavigateComplete2(ByVal sender As Object, ByVal e As AxSHDocVw.DWebBrowserEvents2_NavigateComplete2Event) Handles Web1.NavigateComplete2
    8.         Web1.Navigate("www.yahoo.com")
    9.     End Sub
    All this does is keep reloading yahoo.
    -Rob

  6. #6
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    That is because by calling navigate inside the Navigatecomplete2 event you make it recursive. In other words everytime the page at yahoo.com finishs loading it calls the complete event which in turn then calls for another yahoo page. You can listen to dynamic and inside the complete event check the url and only navigate again if its not yahoo. The code he posted would be put it the Complete event.

  7. #7

    Thread Starter
    Addicted Member VBGangsta's Avatar
    Join Date
    Aug 2003
    Location
    New York
    Posts
    219
    ok i see, but is there a way to use navigate 2 to detect when the browser is done loading?
    -Rob

  8. #8
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    The NavigateComplete2 event only fires when a page (any page) finishes loading. Well any page loaded into the associated AxWeb Browser control.

  9. #9

    Thread Starter
    Addicted Member VBGangsta's Avatar
    Join Date
    Aug 2003
    Location
    New York
    Posts
    219
    So how to I make the cose i posted above work?
    -Rob

  10. #10
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    How is it broken? Or what is it suppose to do?

  11. #11

    Thread Starter
    Addicted Member VBGangsta's Avatar
    Join Date
    Aug 2003
    Location
    New York
    Posts
    219
    it keeps loading yahoo and doesnt load the url variable first. What i really need to do is navigate to url then after that is finished loading get the html(i know how to do this)
    -Rob

  12. #12
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    VB Code:
    1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    2.         name12 = TextBox1.Text
    3.         url = "http://www.outwar.com/playersearch.php?search=" & name12 & "&submit=Search"
    4.         Web1.Navigate(url)
    5.         Label17.Text = name12
    6.     End Sub
    7.     Private Sub web1_NavigateComplete2(ByVal sender As Object, ByVal e As AxSHDocVw.DWebBrowserEvents2_NavigateComplete2Event) Handles Web1.NavigateComplete2
    8.         'put your code to get html here
    9.     End Sub
    If you don't want it to go to yahoo then why is that there? I'm confused.

  13. #13

    Thread Starter
    Addicted Member VBGangsta's Avatar
    Join Date
    Aug 2003
    Location
    New York
    Posts
    219
    I put it there to see what page it whould load first, the page i wanted or the page that was under naviagte2. BUt any way when i use this code the events under navigate2 always happen first.
    -Rob

  14. #14
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    Huh? Also regarding your test, as soon as the first page loaded then it would immediately change to the yahoo page so it doesn't really work also the yahoo page doesn't get called until after the first one is loaded in fact that is what fires it so the one in the button call will always load first.

  15. #15

    Thread Starter
    Addicted Member VBGangsta's Avatar
    Join Date
    Aug 2003
    Location
    New York
    Posts
    219
    When you say loaded do you mean loaded completly or just starting?
    -Rob

  16. #16

    Thread Starter
    Addicted Member VBGangsta's Avatar
    Join Date
    Aug 2003
    Location
    New York
    Posts
    219
    For Example is this instance the msgbox is displayed first and ok must be pressed before the page is even starting to load

    VB Code:
    1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    2.         name12 = TextBox1.Text
    3.         url = "http://www.outwar.com/playersearch.php?search=" & name12 & "&submit=Search"
    4.         Web1.Navigate(url)
    5.         Label17.Text = name12
    6.     End Sub
    7.     Private Sub web1_NavigateComplete2(ByVal sender As Object, ByVal e As AxSHDocVw.DWebBrowserEvents2_NavigateComplete2Event) Handles Web1.NavigateComplete2
    8. msgbox("Test")
    9.     End Sub
    -Rob

  17. #17
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    I think we should understand first when I say loaded I mean it is downloaded, the browser may still be rendering or showing it but it should be completely downloaded or loaded. So the msgbox may halt the thread from showing the page but it 'should' be completed or completely loaded (aka downloaded). In other words the webbrowser should have all of the html from the source.

  18. #18

    Thread Starter
    Addicted Member VBGangsta's Avatar
    Join Date
    Aug 2003
    Location
    New York
    Posts
    219
    So you are saying that i can download the html even though the broswer is still rendering?
    -Rob

  19. #19
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    That 'should' be the case.

  20. #20

    Thread Starter
    Addicted Member VBGangsta's Avatar
    Join Date
    Aug 2003
    Location
    New York
    Posts
    219
    ok thanks, thats what i needed to know
    -Rob

  21. #21
    Frenzied Member dynamic_sysop's Avatar
    Join Date
    Jun 2003
    Location
    Ashby, Leicestershire.
    Posts
    1,142
    if you want the source of the html , use Document_Complete not Navigate_Complete. eg:
    VB Code:
    1. [Color=Blue]Private[/COLOR] [Color=Blue]Sub[/COLOR] AxWebBrowser1_DocumentComplete([Color=Blue]ByVal[/COLOR] sender [Color=Blue]As[/COLOR] [Color=Blue]Object[/COLOR], [Color=Blue]ByVal[/COLOR] e [Color=Blue]As[/COLOR] AxSHDocVw.DWebBrowserEvents2_DocumentCompleteEvent) [Color=Blue]Handles[/COLOR] AxWebBrowser1.DocumentComplete
    2.  
    3.         [Color=Green]'///[/COLOR] [Color=Green]doc[/COLOR] [Color=Green]is[/COLOR] [Color=Green]completely[/COLOR] [Color=Green]loaded[/COLOR] [Color=Green]now
    4. [/COLOR]        MessageBox.Show(AxWebBrowser1.Document.documentelement.innerhtml)
    5.  
    6.     [Color=Blue]End[/COLOR] [Color=Blue]Sub[/COLOR]
    ~
    if a post is resolved, please mark it as [Resolved]
    protected string get_Signature(){return Censored;}
    [vbcode][php] please use code tags when posting any code [/php][/vbcode]

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