【问题标题】:Cannot access NPAPI functions in Firefox Extension无法访问 Firefox 扩展中的 NPAPI 函数
【发布时间】:2011-09-17 23:31:15
【问题描述】:

我无法将 NPAPI 插件加载到 Firefox 扩展中。我现在这样做的方式是该插件已经在 Windows 中注册,所以我通过一个覆盖加载一个嵌入元素,该覆盖被注入到 chrome 中并通过 window.onload 访问。显然 NPAPI 元素已加载,但我无法访问任何本机函数。

这是我的 main.xul:

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

我设置了宽度/高度值,以便可以看到嵌入到 chrome 中。

这是我的 js:

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

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

});

转储:

[object XULElement]
undefined

如果将相同的嵌入代码放入 HTML 文档中,plugin.version 将返回“1000”。 NPAPI 插件已确认工作,因为我可以让它在 HTML 文档中工作并加载到 Chrome 扩展中。

我做错了什么吗?请注意,我必须在 chrome 中加载 NPAPI 插件,而不是按需将其注入页面,因为需要从与网页分开的其他对话框中检索属性。也许还有另一种加载 NPAPI 插件的方法,该插件可以在每次浏览器加载时加载一次,可以从 Firefox 扩展中调用。

如果有任何帮助,NPAPI 是使用 Firebreath 框架构建的。

注意:我已经关注了这个帖子:link,显然可以加载插件,但仍然无法访问任何功能。

谢谢。

【问题讨论】:

    标签: javascript firefox npapi


    【解决方案1】:

    XUL 中没有&lt;embed&gt; 标签,你的意思是使用 HTML &lt;embed&gt; 标签。为这个标签使用 HTML 命名空间:

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

    补充资料:https://developer.mozilla.org/en/Namespaces

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-10-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多