On 21 avr, 17:26, Christian Biesinger <[EMAIL PROTECTED]> wrote:
> Michael R wrote:
> > I use mozilla to load multi frame HTML document and get the DOM built for
> > it. Along with the document there are JavaScript functions loaded.
> > How is it possible to call JavaScript functions from C++ ?
>

I did this for the same purpose:

        nsCOMPtr<nsIScriptGlobalObjectOwner>
theGlobalObjectOwner(do_GetInterface(mWebBrowser));

        if (theGlobalObjectOwner)
        {
                nsIScriptGlobalObject* theGlobalObject;
                theGlobalObject=theGlobalObjectOwner->GetScriptGlobalObject();

                nsIScriptContext* theScriptContext = 
theGlobalObject->GetContext();
/*
UnicodeString is one of our classes, you could'nt find it into gecko
What you have to do is to have an unicode string for the script arg*/

                UnicodeString unicodeScript = 
UnicodeString::fromLatin1(aScript);
                nsAutoString script(unicodeScript.data());

                PRBool        IsUndefined;
                nsresult rv = theScriptContext->EvaluateString(script,
                                                                                
                           nsnull,
                                                                                
                           nsnull,
                                                                                
                           "",
                                                                                
                           1,
                                                                                
                           nsnull,
                                                                                
                           nsnull,
                                                                                
                           &IsUndefined);
        }


Hope itwould be helpfull

philippe

_______________________________________________
dev-tech-xpcom mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-xpcom

Reply via email to