Use webbrowser to obtain the content in the IFRAME of the page

Source: Internet
Author: User

1. Get the document of the frame

Htmldocument htmldoc = webbrowser1.document;
Htmldoc = webbrowser1.document. Window. Frames ["frmrpt"]. Document;

"Frmrpt" is the name of IFRAME;

2. Get the source file of the frame.

MessageBox. Show (webbrowser1.document. Window. Frames ["Main"]. Document. Body. innerhtml );

3. Obtain the htmldocument interface of the frame.

Htmldocument Doc = (htmldocument) webbrowser1.document. domdocument;
Object J;
For (INT I = 0; I <Doc. parentwindow. frames. length; I ++)
J = I;
Htmlwindow2class frame = Doc. parentwindow. frames. Item (ref J) as htmlwindow2class;
If (frame. Name = "Main ")
{ ument. Title );

4. Obtain the ihtmldocument2 interface of the frame.

Ihtmldocument2 Doc = (ihtmldocument2) webbrowser1.document. Window. Frames ["Main"]. Document. domdocument;

5. Get the clicked connection in the frame

Private void webbrowser1_navigating (Object sender, webbrowsernavigatingeventargs E)
String url = webbrowser1.document. Window. Frames ["Main"]. Document. activeelement. getattribute ("src ");

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.