How to call JavaScript file in IEModule or IEToolbar

Add-in Express™ Support Service
That's what is more important than anything else

How to call JavaScript file in IEModule or IEToolbar
Need help to call JavaScript file in IEModule or IEToolbar 
Eugene Astafiev


Add-in Express team


Posts: 8540
Joined: 2007-07-25
Hi Bijay,

Please note that you didn't declare the script on the page. Instead, you run it on the fly.

As you may have seen in the sample project the following code replaces the script on the web page:

mshtml.HTMLDocument doc = this.HTMLDocument;
if (doc != null)
{
    mshtml.IHTMLElementCollection elementCollection1 = doc.getElementsByTagName("script");
    if (elementCollection1 != null)
    {
        for (int i = 0; i < elementCollection1.length; i++)
        {
            mshtml.IHTMLScriptElement scriptElement = elementCollection1.item(i, i) as mshtml.IHTMLScriptElement;
            if (scriptElement != null)
            {
                if (scriptElement.text != null)
                {                             
                    scriptElement.text = "function done(){alert("hello"); }";
                }
                Marshal.ReleaseComObject(scriptElement);
            }
        }
        Marshal.ReleaseComObject(elementCollection1);
    }
}


A test web page were included in the archive you downloaded from our web site.

Anyway, thank you for sharing the solution for others.
.NET, Extended MAPI, Windows Phone & RT
Posted 20 Oct, 2010 04:51:42 Top