mark: easy access to the script context would be probably be a better
idea. for my use case, i really dont need the document.

btw, got it to work on FF2 as well.

so apparently nsembedstring.h and nsIDocument.h are incompatible. i
had to split up the implementation of my class - and dump the
javascript stuff into a different cpp file and define
mozilla_internal_api around it.

heres an alternative implementation for anybody's who's interested.

thanks all!
amitabh

bool CGeckoBasicBrowser::CallJavaScript2()
{
        nsresult rv;
        nsCOMPtr<nsIScriptGlobalObjectOwner> theGlobalObjectOwner =
do_GetInterface(m_webBrowser, &rv);

        if (theGlobalObjectOwner)
        {
                nsIScriptGlobalObject *theGlobalObject=nsnull;
                theGlobalObject = theGlobalObjectOwner->GetScriptGlobalObject();
                nsIScriptContext *sContext = theGlobalObject->GetContext();

                JSContext  *context = nsnull;
                context =(JSContext*)sContext->GetNativeContext();
                if(!context)
                {
                        return false;
                }

                jsval retval;
                JSObject* obj = nsnull;
                obj = JS_GetGlobalObject(context);
                if(!JS_CallFunctionName(context, obj, "init", 0, 0, &retval))
                {
                        return false;
                }
                JSString* jstring = JS_ValueToString(context,retval);
                char *value =JS_GetStringBytes(jstring);
        }

        return true;
}
_______________________________________________
dev-embedding mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-embedding

Reply via email to