最近在做插件的开发,在插件直接掉js的方法,是可以的,但是我要求插件调js的方法,js的方法又调插件中的方法,(因为可能js中的变量要变化,由外边来设定)这样就怎么试都不可以。后来发现,可以通过不插件中不直接掉js方法,而已插件向窗口发消息来调是可以的。
整个流程如下。
<embed id="Splugin" src="plugin\plugin.xml" onevent="SwitchStock('SH510410.fnd');" type="application/npPluginView" width="430" height="530" />
我在我的插件容器中自定义了一个标签,onevent,然后调用swithstock的方法。这样在插件中的子窗口再调用整个插件的方法。
自定义标签的值可以通过:
NPError NPP_New(NPMIMEType pluginType, NPP instance, uint16_t mode, int16_t argc, char* argn[], char* argv[], NPSavedData* saved)
{
if (!instance)
return NPERR_INVALID_INSTANCE_ERROR;
// create a new plugin instance object
// initialization will be done when the associated window is ready
nsPluginCreateData ds;
ds.in