Solved

WebBrowser Control question

Posted on 2003-10-29
2
414 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month11 days, left to enroll

632 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