Search code examples
c++firefoxnpapibrowser-plugin

How can i call C++ Code from JavaScripts with the NPAPI


I saw that one can call the c++ code from JavaScript like this: Calling C++ Code from DHTML

But it is for IE,i use NPAPI to implement a plugin for firefox,and i want to call the method which is defined in c++ code via html file,how can i get it?


Solution

  • You may want to take a look at FireBreath. That's by far the easiest tool for building a plugin to do what you want. Barring that, there are tutorials you can read to learn about building an NPAPI plugin from scratch, though it's a bit of a pain.

    There is also nixysa, though i've never used it myself.

    However you do it (and I strongly recommend FireBreath, since once you have the tools needed to use it you can get a new plugin up in literally 30 minutes or less) you need to expose a scriptable object to the page. If you're using NPAPI directly that means providing an NPObject (discussed in tutorial part 3) that the page will be able to access.