views:

75

answers:

1

I have an NPAPI Plugin that runs in Firefox, but any time that the tab is "torn off" (by dragging the tab into space so a new window is formed), the plugin is destroyed and recreated. The problem is that the plugin needs to be initialized with information from an Ajax call, and I cannot find any way in Javascript to detect this, so the plugin is not getting the necessary initialization information.

So, any ideas as to how to detect this event and/or make the plugin not be destroyed/recreated when the tab is torn off?

A: 

What operating system are you dealing with? If it is actually destroying your plugin and recreating it, you could always have the plugin attempt to call a javascript method on startup.

Specify the name of the function in a param tag and then on plugin startup, attempt to get a reference to that method by calling NPN_GetProperty on the window NPObject (which you can get by calling NPN_GetValue(NPNVWindowNPObject, &npobjectptr) and then calling NPN_GetProperty(npp, npobjectptr, NPN_GetStringIdentifier(functionname), &destObj)

Then you can invoke that method with a reference to your plugin (which you can get again with NPN_GetValue) and the js function will know that it's time to initialize your plugin (again?).

You could do other things as well, such as store initialization data in global space and try to figure out a way to detect that it should be the same plugin instance... not sure how to be sure it's supposed to be the same one, though.

Taxilian
The OS is Windows (with Mac support soon, and Linux support next). I like the initialization method; I'll give that a try.
Nick Lassonde