we could get the method below to work on pelle's win32_test / gecko
1.9. it calls a JS function init() which is in the embedded webpage.
unfortunately when we tried to migrate this to gecko 1.8.1 (FF2), the
moment i add #include "nsIDocument.h", i get a
"fatal error C1189: #error : Cannot use internal string classes
without MOZILLA_INTERNAL_API defined. Use the frozen header
nsStringAPI.h instead."
i dont know whether this is related to gecko or something else but its
driving me up the wall :(
-----------------
NS_IMETHODIMP MozEmbed::CallJavaScript()
{
nsresult rv;
//The nsIDOMDocument interface represents the entire HTML or XML
document
nsCOMPtr<nsIDOMDocument> domDoc;
rv = webNavigation->GetDocument(getter_AddRefs(domDoc));
if (NS_FAILED(rv))
return rv;
nsCOMPtr<nsIDocument> doc;
doc = do_QueryInterface(domDoc,&rv);
if (NS_FAILED(rv))
return rv;
nsIScriptGlobalObject *sglobalobject=nsnull;
sglobalobject = doc->GetScriptGlobalObject();
if(!sglobalobject)
return -1;
nsIScriptContext *sContext=nsnull;
sContext = sglobalobject->GetContext();
if(!sContext)
return -1;
JSContext *context = nsnull;
context =(JSContext*)sContext->GetNativeContext();
if(!context)
return -1;
JSObject* obj = nsnull;
jsval retval;
obj = JS_GetGlobalObject(context);
//JS function Init() returns a string
if(!JS_CallFunctionName(context, obj, "Init", 0, 0, &retval))
return JS_FALSE;
JSString* jstring = JS_ValueToString(context,retval);
char *value = JS_GetStringBytes(jstring);
return NS_OK;
}
_______________________________________________
dev-embedding mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-embedding