简体   繁体   English

无法访问Firefox扩展中的NPAPI函数

[英]Cannot access NPAPI functions in Firefox Extension

I'm having trouble getting an NPAPI plugin to load in a Firefox Extension. 我无法让NPAPI插件加载到Firefox扩展中。 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. 我现在使用的方式是插件已在Windows中注册,因此我通过覆盖层加载了嵌入元素,该覆盖层被注入chrome中并通过window.onload访问。 Apparently the NPAPI element is loaded but I cannot access any native functions. 显然NPAPI元素已加载,但是我无法访问任何本机函数。

Here is my main.xul: 这是我的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. 我设置了width / height值,以便可以看到嵌入到chrome中的嵌入。

Here is my js: 这是我的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". 如果将相同的嵌入代码放入HTML文档中,plugin.version将返回“ 1000”。 The NPAPI plugin is confirmed working as I can get it working in the HTML document and loaded in a Chrome Extension. 可以确认NPAPI插件可以正常工作,因为我可以在HTML文档中找到它并加载到Chrome扩展程序中。

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. 请注意,我必须在chrome中加载NPAPI插件,而不是按需将其注入到页面中,因为需要从与网页分开的其他对话框中检索属性。 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. 也许还有另一种加载NPAPI插件的方法,该插件每次浏览器加载一次即可加载一次,可以从Firefox扩展中调用。

If it is any help, the NPAPI was built with the Firebreath framework. 如果有帮助,可以使用Firebreath框架构建NPAPI。

Note: I've followed through this thread: link and obviously can get the plugin loaded but still cannot access any functions. 注意:我已经遵​​循了这个线程: link ,显然可以加载插件,但是仍然无法访问任何功能。

Thanks. 谢谢。

There is no <embed> tag in XUL , you mean to use the HTML <embed> tag. XUL中没有<embed>标记,您的意思是使用HTML <embed>标记。 Use the HTML namespace for this tag: 使用此标签的HTML名称空间:

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

Additional information: https://developer.mozilla.org/en/Namespaces 附加信息: https : //developer.mozilla.org/en/Namespaces

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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