Solved

WebBrowser Control question

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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…
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…

679 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