Click here to Skip to main content
15,916,846 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am developing an IE Extension. I want insert a signature(Image) inside the body of Compose Text Editor for Gmail in IE. But i could insert it outside of the body since the Compose Text Editor has IFrame i am not able to get the inner HTML of the IFrame through BHO. It throws JScript run time error. Could any one of you help me to resolve this as it is very urgent for me to complete it?
Posted

1 solution

I found the answer for this.
Timeout has to be set before calling the script in OnDocumentComplete Event.

sLineCard is HTML source for image which has to be displayed inside the iFrame of Gmail old Compose.

document.parentWindow.setTimeout(scriptSiggitt(sLineCard), 50);

public string scriptSiggitt(string sLineCard)
{
    string sImageCard = " var htmlHeader; " +
                        "    var htmlBody; " +
                        "    var f; " +
                        "    var y; " +
                        "    var iFrame = document.getElementsByTagName('iframe'); " +
                        "    for (var i = 0; i < iFrame.length; i++) { " +
                        "        if (iFrame[i].className.toString() == 'Am Al editable') { " +
                        "            f = document.getElementById(iFrame[i].id); " +
                        "            y = (f.contentWindow || f.contentDocument); " +
                        "            if (y.document) y = y.document; " +
                        "            htmlHeader = y.head.innerHTML; " +
                        "            htmlBody = y.body.innerHTML; " +
                        "            if(htmlBody=='') { "+ 
                        "            f.contentWindow.document.body.innerHTML = \"<br /><br/><br />" + sLineCard + " \" + f.contentWindow.document.body.innerHTML ; " +
                        "            } "+
                        "            else "+
                        "            { " +
                        "            f.contentWindow.document.body.innerHTML = \"<br /><br /><br />" + sLineCard + " \" + f.contentWindow.document.body.innerHTML ; " +
                        "            } "+
                        "        } " +
                        "    } ";
            return sImageCard;
        }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900