Solved

WebBrowser Control question

Posted on 2003-10-29
2
400 Views
Last Modified: 2010-05-01
Im using the WebBrowser control under Visual Studio 2003 .NET Enterprise.  So far I've been able to connect to my online bank, which makes use of the HTTPS protocol.  Login and password field are programmtically set then I use the IHTMLElement method .Click() to programmtically click a specific anchor, which it generates on onclick javascript event so that it does what it has to do before actually making the https request.  Eventually the WebBrowser is taken to another webpage.  I use the following:
===========
//Get the current URL
string CurrentURL=((IHTMLDocument2)hhh.document).url;
//Click the anchor
hhh.click();
// Now wait until the webpage URL changes before looking at the document HTML contents
// For some reason "WebBrowser.Busy" doesnt work
while (WebBrowser.LocationURL == vv)
{Application.DoEvents();}
// Retrieve the document's HTML cotents
IHTMLDocument2 newPage = (IHTMLDocument2)WebBrowser.Document;
Console.WriteLine(newPage.body.innerHTML);
===========

The HTML code that is returned back from newPage.body seems to be correct however it is cut off, though it is clipped at a very precise area (the last </Table> tag is shown).  Why is that?  Does this have to do with the .Click() method used to navigate to a new page?  And the returned innerHTML has all <IMG> tags removed.  I thought body.innerHTML is supposed to return back all html between the <BODY> tags.  What gives?

Thanks.


0
Comment
Question by:aniston
2 Comments
 
LVL 17

Accepted Solution

by:
zzzzzooc earned 125 total points
ID: 9646763
You probably retrieve the document before it fully loads. You should try:

    Do Until WebBrowser1.ReadyState = READYSTATE_COMPLETE
        DoEvents
    Loop

Of course you'll need to change it to fit .NET. :)
0
 

Author Comment

by:aniston
ID: 9647351
I dont know if this makes a difference but the returned webpage HTML does NOT have a <BODY></BODY> tag.  Though body.innerHTML does still return back something.

Using ".ReadyState" produced the same results, clipped html data.  Again, the returned html is being truncated at the exact same region everytime.  It almost seems intentional by the browser control.  Heres the returned HTML using "(IHTMLDOCUMENTwebPage.body.innerHTML":
============
<!-- beginning of top nav --><A name=top></A>
<TABLE cellSpacing=0 cellPadding=0 width="100%" bgColor=#990033 border=0>
<TBODY>
<TR height=78>
<TD align=left>
<TABLE cellSpacing=0 cellPadding=0 width=640 bgColor=#990033 border=0>
<TBODY>
<TR>
.
.
.
<TD bgColor=#ffffcc><IMG height=1 src="/english/images/bsp.gif" width=1></TD>
<TD bgColor=#ffffcc><IMG height=1 src="/english/images/bsp.gif" width=1></TD></TR>
<TR vAlign=bottom height=24>
<TD colSpan=3></TR></TBODY></TABLE></TR></TBODY></TABLE></TR></TBODY></TABLE>
=============

The returned contents is exaacty 2956 bytes.

Any other promising leads would still be apreciated!
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now