Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

WebBrowser Control question

Posted on 2003-10-29
2
Medium Priority
?
418 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 375 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
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

876 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