WebBrowser Control

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Lance

    #1

    WebBrowser Control

    Hi All,

    Given a collection of links, how can I send them to a WebBrowser Control so
    that I can manipulate it's document? Ok, that's way too simplified of a
    question. I know how to send a link to a WebBrowser:

    /////
    WebBroweser1.Na vigate(Link)
    /////

    but I can figure out how to send several links in succession. In my test,
    I've got a simple collection that contains 5 strings. Pressing a command
    button performs:

    /////
    For Each s As String In links
    WebBrowser1.Nav igate(s)
    Next
    /////

    and in the WebBrowser1's DocumentComplet ed Event is:

    /////
    Dim doc As HtmlDocument = WebBrowser1.Doc ument
    Debug.Print(doc .Url.ToString)
    /////

    However, the only Url string ever printed to the immediate window is the
    last one in the collection, and all the WebBrowser1 window ever shows is
    that last webpage.

    I realize this probably has something to do with synchronization , but I'm
    not sure how to resolve this.

    Thanks,
    Lance


  • GhostInAK

    #2
    Re: WebBrowser Control

    Hello Lance" chuckyboy81070-at-onehotpotatoime anhotmail.com,

    ..Navigate() is an asynch method. The navigation and remdering is passed
    off to the web browser control, which uses a separate thread(s) to do the
    work.. and immediately returns from the .Navigate method.

    The correct method for navigating multiple URLs in succession.. which you
    should have guessed from your investigations had you just applied yourself..
    is to navigate to each successive URL from within the DocumentComplet ed event.

    -Boo
    Hi All,
    >
    Given a collection of links, how can I send them to a WebBrowser
    Control so that I can manipulate it's document? Ok, that's way too
    simplified of a question. I know how to send a link to a WebBrowser:
    >
    /////
    WebBroweser1.Na vigate(Link)
    /////
    but I can figure out how to send several links in succession. In my
    test, I've got a simple collection that contains 5 strings. Pressing
    a command button performs:
    >
    /////
    For Each s As String In links
    WebBrowser1.Nav igate(s)
    Next
    /////
    and in the WebBrowser1's DocumentComplet ed Event is:
    >
    /////
    Dim doc As HtmlDocument = WebBrowser1.Doc ument
    Debug.Print(doc .Url.ToString)
    /////
    However, the only Url string ever printed to the immediate window is
    the last one in the collection, and all the WebBrowser1 window ever
    shows is that last webpage.
    >
    I realize this probably has something to do with synchronization , but
    I'm not sure how to resolve this.
    >
    Thanks,
    Lance


    Comment

    • Lance

      #3
      Re: WebBrowser Control

      Thanks Boo. You're right, I would have eventually figured that out. I
      tried for several hours and just thought I'd drop a note to the group before
      the weekend.

      Thanks again,
      Lance

      "GhostInAK" <ghostinak@gmai l.comwrote in message
      news:be1391bf17 5808c8a1799764d 8d6@news.micros oft.com...
      Hello Lance" chuckyboy81070-at-onehotpotatoime anhotmail.com,
      >
      .Navigate() is an asynch method. The navigation and remdering is passed
      off to the web browser control, which uses a separate thread(s) to do the
      work.. and immediately returns from the .Navigate method.
      >
      The correct method for navigating multiple URLs in succession.. which you
      should have guessed from your investigations had you just applied
      yourself.. is to navigate to each successive URL from within the
      DocumentComplet ed event.
      >
      -Boo
      >
      >Hi All,
      >>
      >Given a collection of links, how can I send them to a WebBrowser
      >Control so that I can manipulate it's document? Ok, that's way too
      >simplified of a question. I know how to send a link to a WebBrowser:
      >>
      >/////
      >WebBroweser1.N avigate(Link)
      >/////
      >but I can figure out how to send several links in succession. In my
      >test, I've got a simple collection that contains 5 strings. Pressing
      >a command button performs:
      >>
      >/////
      >For Each s As String In links
      >WebBrowser1.Na vigate(s)
      >Next
      >/////
      >and in the WebBrowser1's DocumentComplet ed Event is:
      >>
      >/////
      >Dim doc As HtmlDocument = WebBrowser1.Doc ument
      >Debug.Print(do c.Url.ToString)
      >/////
      >However, the only Url string ever printed to the immediate window is
      >the last one in the collection, and all the WebBrowser1 window ever
      >shows is that last webpage.
      >>
      >I realize this probably has something to do with synchronization , but
      >I'm not sure how to resolve this.
      >>
      >Thanks,
      >Lance
      >
      >
      >

      Comment

      Working...