nsIScriptContext hasn't yet been on our list of interfaces to bless for
public consumption, especially since it may change drastically as part
of the current DOM idlc glue -> XPConnect transition. If sticking to the
public set of interfaces is not an issue, you can do the following:
QI a nsIDOMWindow to nsIScriptGlobalOject
obtain an nsIScriptContext by using the
nsIScriptGlobalObject::GetContext() accessor
use nsIScriptContext::EvaluateString to evaluate your script
Be warned that these interfaces may change in the near future.
--Vidur
Brendan Eich wrote:
> nk wrote:
>
>> I have written a C++ XPCOM object. I would like to call a javascript
>> function from this object which is defined in html page hosting XPCOM
>> object.
>>
>> In other words, I am looking for something equivalent to the
>> following in IE
>> pIHTMLWindow->execScript(bstrScript,NULL,&vtResult);
>>
>> where bstrScript could have any JavaScript code.
>
>
> This is a good question for the embedding newsgroup, I think. The
> evaluate-script methods in nsIScriptContext are the closest things I
> can think of, but I am not up on the latest thinking in how to expose
> them via embedding APIs. Jud, vidur: any hope?
>
> /be
>