简体   繁体   中英

Cannot access NPAPI functions in Firefox Extension

I'm having trouble getting an NPAPI plugin to load in a Firefox Extension. The way I'm doing it now is the plugin is already registered in Windows, so I load an embed element via an overlay which is injected into the chrome & accessed via window.onload. Apparently the NPAPI element is loaded but I cannot access any native functions.

Here is my main.xul:

<overlay ...>
  <window id="main-window">
    <embed type="application/x-myplugin" id="myplugin" width="300" height="300"></embed>
  </window>
</overlay>

I set the width/height values so I can see the embed inserted into the chrome.

Here is my js:

window.addEventListener("load", function () {  

  var plugin = document.getElementById("myplugin");
  dump(plugin + "\n");
  dump("version: " + plugin.version + "\n");

});

The dump:

[object XULElement]
undefined

If the same embed code was placed into an HTML document, plugin.version would return "1000". The NPAPI plugin is confirmed working as I can get it working in the HTML document and loaded in a Chrome Extension.

Is there something I'm doing wrong? Note that I have to load the NPAPI plugin inside the chrome as opposed to injecting it on demand into the page as properties will need to be retrieved from other dialog boxes separate from the web page. Perhaps there is another way to load an NPAPI plugin that can be loaded once per browser load which can be called from a Firefox Extension.

If it is any help, the NPAPI was built with the Firebreath framework.

Note: I've followed through this thread: link and obviously can get the plugin loaded but still cannot access any functions.

Thanks.

There is no <embed> tag in XUL , you mean to use the HTML <embed> tag. Use the HTML namespace for this tag:

<embed xmlns="http://www.w3.org/1999/xhtml" ...></embed>

Additional information: https://developer.mozilla.org/en/Namespaces

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM