Problem with Document from WebBrowser control

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

    Problem with Document from WebBrowser control

    I am at my wits' end.

    I have the following code:

    WebBrowser1.Nav igate ("c:\path\page. htm")
    Text1.Text = WebBrowser1.Doc ument.Links.len gth

    Where the page.htm has the following HTML:

    <html>
    <head><title> </title></head>
    <body>
    <h1>Test</h1>
    <a href="somepage. htm">Link</a><br>
    <a href="anotherpa ge.htm">Second Link</a><br>
    <a href="andonemor e.htm">Third Link</a><br>
    Test
    </body>
    </html>

    Page loads into browser control fine, but the value that appears in
    the TextBox control is "0". This is the same value I get when I query
    any of the collections in the Document object. I cannot figure out
    what magic I need to perform to be able to analyze the document object
    that is current loaded in the WebBrowser control. Any help you guys
    could give me would be greatly appreciated.

    Further info:

    VB6
    WinXP

    TIA

    Mark
  • Konstantin Veretennicov

    #2
    Re: Problem with Document from WebBrowser control

    maryesme@shore. net (Mark) wrote in message news:<cf5333d.0 407080731.2d46a 13f@posting.goo gle.com>...[color=blue]
    > I am at my wits' end.
    >
    > I have the following code:
    >
    > WebBrowser1.Nav igate ("c:\path\page. htm")
    > Text1.Text = WebBrowser1.Doc ument.Links.len gth
    >
    > Where the page.htm has the following HTML:
    >
    > <html>
    > <head><title> </title></head>
    > <body>
    > <h1>Test</h1>
    > <a href="somepage. htm">Link</a><br>
    > <a href="anotherpa ge.htm">Second Link</a><br>
    > <a href="andonemor e.htm">Third Link</a><br>
    > Test
    > </body>
    > </html>
    >
    > Page loads into browser control fine, but the value that appears in
    > the TextBox control is "0". This is the same value I get when I query
    > any of the collections in the Document object. I cannot figure out
    > what magic I need to perform to be able to analyze the document object
    > that is current loaded in the WebBrowser control. Any help you guys
    > could give me would be greatly appreciated.
    >
    > Further info:
    >
    > VB6
    > WinXP
    >
    > TIA
    >
    > Mark[/color]

    AFAIK, WebBrowser.Navi gate works asynchronously, i.e. page may still
    be loading/parsing when you query HTML DOM for links.length.

    Try to delay queries until page is completely loaded. Check out
    ReadyState property and NavigateComplet e event.

    Maybe there is a way to turn off asynchronous loading
    (like in DOMDocument.asy nc = False), but not to my knowledge.

    - kv

    Comment

    Working...