tags:

views:

149

answers:

1

I have some dll that implements some logic. I want to create wrapper that will be accessible from JavaScript of HTML page in Mozilla browser. I have found npruntime framework,but it seems supports only window control, i don't need GUI. I am looking for mechanism like ActiveXObject implemented in Internet Explorer.

+2  A: 

You are looking for the NPAPI. Its documented here on MDC, here is an excellent tutorial for it.

There are alternatives to doing it directly however, SWIG can generate code to interface NPAPI (if i remember that right) and there is also FireBreath which hides browser and platform differences from you.

NPAPI was designed to display alternative content in websites, thus non-drawing plugins aren't explicitly supported. If you know however that your plugin won't get shown in the page anyway (i.e. the object or embed element will be hidden anyway), you don't have to do anything in NPP_SetWindow() or if you get drawing events in NPP_HandleEvents(). Alternatively you can just draw some static background.

The best equivalent to ActiveXObject() would be to have a factory method for your plugin that creates new scriptable objects, i.e. something like myPlugin.createObject().

Georg Fritzsche
I have found there:You can write plug-ins that are drawn in their own native windows or frames on a web page.But i don't need GUI.
Rouslan
You can simply use window-less plugins: https://developer.mozilla.org/en/Gecko_Plugin_API_Reference:Plug-in_Basics#Windowed_and_Windowless_Plug-ins ... and even with windowed plugins, you don't *need* to do drawing.
Georg Fritzsche
The best equivalent to `ActiveXObject` would probably be a factory method on your plugins that returns new scriptable objects.
Georg Fritzsche
I don't need to do drawing, but must plug-in implement drawing function?
Rouslan
You can just do nothing on `NPP_SetWindow()` or incoming drawing events coming in on `NPP_HandleEvent()` if you don't want to draw and you expect users to not show your plugin in the page (i.e. the embed or object element is hidden). Alternatively, just draw a black background or something like that.
Georg Fritzsche
Thanks! I've get that solution before,but hoped for clean windowless solution.
Rouslan
It has historic reasons, NPAPI was designed for displaying alternative/unsupported content in websites.
Georg Fritzsche