By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,750 Members | 1,456 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,750 IT Pros & Developers. It's quick & easy.

Problem with Document from WebBrowser control

P: n/a
I am at my wits' end.

I have the following code:

WebBrowser1.Navigate ("c:\path\page.htm")
Text1.Text = WebBrowser1.Document.Links.length

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="anotherpage.htm">Second Link</a><br>
<a href="andonemore.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
Jul 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
ma******@shore.net (Mark) wrote in message news:<cf*************************@posting.google.c om>...
I am at my wits' end.

I have the following code:

WebBrowser1.Navigate ("c:\path\page.htm")
Text1.Text = WebBrowser1.Document.Links.length

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="anotherpage.htm">Second Link</a><br>
<a href="andonemore.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


AFAIK, WebBrowser.Navigate 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 NavigateComplete event.

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

- kv
Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.