Solved

Accessing the objects within an IFrame

Posted on 2009-04-06
2
909 Views
Last Modified: 2013-11-23
I need to be able to access the elements in an IFrame to read the values and write them.
I have code to do this within Pages and Frames where I have previously dealt with the All property of the IHTMLDocument(s) which is an IHTMLCollection. The All property of the HTMLIFrame and the IHTMLElement is an IDespatch.

I would welcome any advice dealing with this property, for example what collection type does it actually return? I have checked for IHTMLDocument2 and IHTMLElementCollection and the IFrame doees not appear to support them.

Are there any Gotchas?

How can I get from the IDespatch to the equivalent of the document or HTMLCollection object (if there is one) that one gets from iterating through the enumerator of the OleContainer for a standard Frame.

My current code for dealing with pages and frames and the test code I have written for IFrames is below.

The background to this work is that we write Speech Recognition Software. A lot of ouir users are hospital departments and assiting disabled people to retain their jobs. This means providing workflows which they can drive by voice, filling in our voice activated dialogs by voice and our workflow software then puts the data into the relevant field. A lot of the applications they use are delivered through browsers with the pages generated by 3/4th generation development systems. Quite a lot of these use IFrames.
Our own website uses Joomla as a Content Management System and the Editors for that are delivered in IFrames.

Code now used to find the Frames and the associatied document NewDoc (IHTMLDocument2)
This was from an answer to a previous question and works well.
       if (Supports(CurrDoc, IOleContainer, Container)) and
         (Container.EnumObjects(OLECONTF_EMBEDDINGS, Enumerator) = S_OK)
      then begin
            while Enumerator.Next(1, Unknown, @Fetched) = S_OK do
            begin
            Inc(FrameNo);
             if (Supports(Unknown, IWebBrowser2, Browser)) and
                (Supports(Browser.Document, IHTMLDocument2, NewDoc))
 
Test code trying to find a Document (IHTMLDocument2) interface in the IFrame
    if Supports(CurrItem, HTMLIFrame, fIFrame)
  then begin
        edtTag.Text := 'Got IFrame';
        if Supports(fIFrame, IHTMLFrameBase, fFrameBase)
        then WrkStr := ' +'
        else WrkStr := ' -';
        EdtTag.Text := EdtTag.Text+WrkStr+'FB';     //This is Supported
        if Supports(fIFrame, IHTMLFrameBase2, fFrameBase2)
        then WrkStr := ' +'
        else WrkStr := ' -';
        EdtTag.Text := EdtTag.Text+WrkStr+'FB2';    //This is Supported
        if Supports(fIFrame, IHTMLFrameBase3, fFrameBase3)
        then WrkStr := ' +'
        else WrkStr := ' -';
        EdtTag.Text := EdtTag.Text+WrkStr+'FB3';     //This is Supported
        if (Supports(fIFrame, IHTMLElementCollection, TestColl))
        then WrkStr := ' +'
        else WrkStr := ' -';
        EdtTag.Text := EdtTag.Text+WrkStr+'Col';     //This is not Supported
        if (Supports(fIFrame, IOleContainer, TestCont))
        then WrkStr := ' +'
        else WrkStr := ' -';
        EdtTag.Text := EdtTag.Text+WrkStr+'Cnt';     //This is not Supported
        if (Supports(fIFrame, IHTMLDocument2, TestDoc))
        then WrkStr := ' +'
        else WrkStr := ' -';
        EdtTag.Text := EdtTag.Text+WrkStr+'Doc1';      //This is not Supported
        if (Supports(fIFrame, IWebBrowser2, TestBrowse))
        then WrkStr := ' +'
        else WrkStr := ' -';
        EdtTag.Text := EdtTag.Text+WrkStr+'Brow';    //This is Supported
        if (Supports(TestBrowse, IHTMLDocument2, TestDoc))
        then WrkStr := ' +'
        else WrkStr := ' -';
        EdtTag.Text := EdtTag.Text+WrkStr+'Doc2';
        end
  else edtTag.Text := 'NOT got IFrame';

Open in new window

0
Comment
Question by:GHG-RCH
[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 5

Accepted Solution

by:
Mechanic_Kharkov earned 500 total points
ID: 24075720
0
 

Author Comment

by:GHG-RCH
ID: 24078684
Thank you for this reference, it gave me enough to proceed. On this bais I have closed the question, though I have used the second suggested approach and wish to try the first one also.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

726 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