从chrome扩展调用函数

时间:2011-11-14 05:46:24

标签: npapi function-call

我正在为chrome创建扩展程序。我正在使用NPAPI来调用用C语言编写的代码。根据链接http://code.google.com/chrome/extensions/npapi.html

将“.so”文件(NPAPI插件的输出)链接到chrome

这是我的manifest.json

{
  "name": "My extension",
  ...
  "plugins": [
    { "path": "../myplugin.so", "public": true },

  ],

}

这是我的background.html(chrome插件的背景页面)

<embed type="application/x-myplugin" id="myplugin">
<script>
  var plugin = document.getElementById("myplugin");
  var result = plugin.testfunction();  // call a method in your plugin
  console.log("my plugin returned: " + result);
</script>


I'm getting an error "Uncaught TypeError: Object #<HTMLObjectElement> has no method 'testfunction'"

How can I fix this? 

0 个答案:

没有答案