使用BHO的IE浏览器扩展 [英] IE Browser Extension using BHO

查看:77
本文介绍了使用BHO的IE浏览器扩展的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发IE扩展程序。我想在IE的Compose Text Editor for Gmail中插入一个签名(Image)。但是我可以将它插入到身体之外,因为Compose Text Editor有IFrame我无法通过BHO获得IFrame的内部HTML。它会引发JScript运行时错误。你们中的任何人都可以帮我解决这个问题,因为我很急需完成它吗?

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?

推荐答案

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;
        }


这篇关于使用BHO的IE浏览器扩展的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆