Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4008238
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T08:43:48+00:00 2026-05-20T08:43:48+00:00

I’m developing an IE8+ BHO plugin. For now I’m simply trying to insert a

  • 0

I’m developing an IE8+ BHO plugin. For now I’m simply trying to insert a text into an iframe (class=”Al Ai Editable”) contained in another iframe (id=”canvas_frame”).

I managed to obtain the IHTMLElement of the iframe i want to add text to (the class=”Al Ai editable”). I can prove this by the fact that the el variable which is of type IHTMLElement :

el->get_className(&cl); //Al Ai editable

is correctly displaying the class of the iframe in the MessageBox.

The problem i have now is that i can’t access the body element of this respective iframe.

For example when i try to access the body of the iframe with its id using the following code then this crashes the browser:

el->getElementById(L":d6", &el); // ":d6" is the id of the body inside the iframe

Also, trying to obtain the inner HTML or inner Text i simply obtain an empty string:

el->get_innerHTML(&htm);
MessageBox(hwnd, htm, L"BHO cl", MB_OK);

or

el->get_innerText(&htm);
MessageBox(hwnd, htm, L"BHO cl", MB_OK);

displays nothing (“”).

I’ve even tryed the el->get_children method and that didn’t help either.

Here’s a the whole function :

void CgmailAdderBHO::checkIframes(HWND hwnd, IDispatch *lpDisp) {

USES_CONVERSION;

if (lpDisp) {
    IOleContainer* pContainer;

    // Get the container
    HRESULT hr = lpDisp->QueryInterface(IID_IOleContainer,
                                       (void**)&pContainer);
    lpDisp->Release();

    if (FAILED(hr)) {
      return;
    }

   IEnumUnknown* pEnumerator;

   // Get an enumerator for the frames
   hr = pContainer->EnumObjects(OLECONTF_EMBEDDINGS, &pEnumerator);
   pContainer->Release();

   if (FAILED(hr)) {
      return;
   }

   IUnknown* pUnk;
   ULONG uFetched;

   // Enumerate and refresh all the frames
   for (UINT i = 0; S_OK == pEnumerator->Next(1, &pUnk, &uFetched); i++)
   {
      IWebBrowser2* pBrowser;

      hr = pUnk->QueryInterface(IID_IWebBrowser2, (void**)&pBrowser);
      pUnk->Release();

     if (SUCCEEDED(hr))
     {
         // process the iframe
         CComPtr<IDispatch> docDisp;
        pBrowser->get_Document(&docDisp);
        CComQIPtr<IHTMLDocument3> doc = docDisp;
        CComQIPtr<IHTMLElementCollection> iframes;

        HRESULT hr = doc->getElementsByTagName(SysAllocString(L"body"), &iframes);
        long length;
        iframes->get_length(&length);
        CComVariant itemIndex(0);
        CComVariant empty;
        CComQIPtr<IDispatch> htmlEl;

        iframes->item(itemIndex, empty, &htmlEl);
        CComQIPtr<IHTMLElement> el = htmlEl;
        BSTR cl;
        BSTR cln(L"cP");
        el->get_className(&cl);

        if (cl && strcmp(OLE2A(cl), "cP") == 0) {
            //this is the canvas_frame
            // check if it has any other subframes
            BSTR html;
            el->get_innerHTML(&html);

            doc->getElementsByTagName(SysAllocString(L"iframe"), &iframes);
            if (iframes) {
                iframes->get_length(&length);
                if (length > 0) {
                    //MessageBox(hwnd, L"We are on compose!", L"BHO", MB_OK);
                    //add encrypt button code here
                    iframes->item(itemIndex, empty, &htmlEl);
                    el = htmlEl;
                    el->get_className(&cl); //Al Ai editable

                    BSTR htm;
                    el->get_innerHTML(&htm);
                    MessageBox(hwnd, cl, L"BHO cl", MB_OK);
                    MessageBox(hwnd, htm, L"BHO cl", MB_OK);

                    CComQIPtr<IHTMLDocument3> docul = htmlEl;

                    //docul->getElementById(L":d6", &el);

                    break; // found iframe ; now exit for
                }
            }
        }
        pBrowser->Release();
      }
   }
   pEnumerator->Release();
}
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T08:43:49+00:00Added an answer on May 20, 2026 at 8:43 am

    The reason for the error is a security restriction. You’re accessing a nested iframe so you’ll need to reconfigure your function to work recursively to bypass the restriction.

    See how you access the first level of iframes using

    hr = pContainer->EnumObjects(OLECONTF_EMBEDDINGS, &pEnumerator);

    but then use

    doc->getElementsByTagName(SysAllocString(L"iframe"), &iframes);'
    

    to access the nested iframes ? That’s the error, you need to access the nested iframes the same as the first ones, using EnumObjects and then getting the IWebBrowser2 interface.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
this is what i have right now Drawing an RSS feed into the php,
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a bunch of posts stored in text files formatted in yaml/textile (from
I am trying to loop through a bunch of documents I have to put
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.