Unless your JS code is a built in DOM style event like onclick, you will need to create a JavaScript function object structured as an XPCOM component. The component will need to implement an interface defined in IDL (you can define your own) so that it can be easily called from C++ or elsewhere.
For an example of this - see the JS version of the nsSample component in the XPCOM folder in the moz source tree. This is the "clean" way to do it without resorting to digging through the JS engine implementation. -rick Sergej Marsnjak wrote: > Hello! > > I'm writing a plugin for Netscape. Because LiveConnect is no longer > supported, I'm using XPConnect. > I know how to call my C++ methods from javaScript (it already works well). > But how to call javaScript _from_ C++? > > Because I have already written an ActiveX control for IExplorer, which fires > events, I have written javaScript in HTML like this: > > <SCRIPT LANGUAGE="JavaScript" FOR="MyObject" EVENT="OnSomething(SomeValue)"> > // do something > </SCRIPT> > > So, how to call this "OnSomething" event (or even some function) from > Netscape's plugin? I read a lot of documentation, but didn't find anything > useful. I don't know which interface to use and where to get it (maybe > NPN_GetValue?). > > Thanks, > Sergej Marsnjak > > >
