Hi all,
I've implemented my app with embedded Gecko, and it works fine. Now I
want to use some advanced JavaScript to control things. That means that
I want to expose an interface from my application to JavaScript. In the
embedding FAQ it mentions the method AddCategoryEntry with parameter
JAVASCRIPT_GLOBAL_PROPERTY_CATEGORY. But I can't seem to access any
object that way.
Also I would like my application to call JS. Especially JS functions
that are defined on the currently loaded page. I can execute global
functions like alert() fine, but nothing that has been defined in HTML.
I use this to execute my JS:
nsCOMPtr<nsIDocShell> theDocShell(do_GetInterface(iWebBrowser));
if (theDocShell) {
nsCOMPtr<nsIScriptGlobalObjectOwner>
theGlobalObjectOwner(do_GetInterface(theDocShell));
if (theGlobalObjectOwner) {
nsIScriptGlobalObject *theGlobalObject =
theGlobalObjectOwner->GetScriptGlobalObject();
nsIScriptContext *theScriptContext =
theGlobalObject->GetContext();
nsEmbedString theScript(aScript);
nsIPrincipal *thePrincipal = nsnull;
PRBool IsUndefined;
nsresult rv = theScriptContext->EvaluateString(theScript, nsnull,
thePrincipal, "", 1, nsnull, &theReturnValue, &IsUndefined);
}
}
_______________________________________________
dev-embedding mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-embedding