Solved

WebBrowser Control question

Posted on 2003-10-29
2
404 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

813 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

17 Experts available now in Live!

Get 1:1 Help Now