开发者

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开发者_StackOverflow社区 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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜