在你扩展的manifest.json文件中加入一个节,描述如何找到你的插件,以及其他一些信息,:
{ "name": "My extension", ... "plugins": [ { "path": "content_plugin.dll", "public": true }, { "path": "extension_plugin.dll" } ], ... }
"path" 属性用于描述如何找到你的插件,路径是相对于manifest文件位置的。 "public" 属性指明是否允许普通页面加载你的插件,默认是false,也就是只有你的扩展才能加载这个插件。
创建一个HTML文件,mime-type为:application/x-my-extension" ,用于加载你的插件。
<embed type="application/x-my-extension" id="pluginId"> <script> var plugin = document.getElementById("pluginId"); var result = plugin.myPluginMethod(); // call a method in your plugin console.log("my plugin returned: " + result); </script>
这个页面可以被后台页面包含,或者任何你扩展会用到的其他页面。如果你的插件的 "public" 属性是true,,你可以通过脚本在页面中直接使用它。
这篇文档对您是否有帮助?