firefox扩展加载javascript文件

时间:2011-03-14 07:42:11

标签: javascript firefox-addon

我有一个firefox扩展,我加载了一个外部javascript文件来访问一些文件编写功能。它适用于Windows Vista但不适用于Windows 7.我的加载javascript文件的代码是:

onLoad: function() {
// initialization code
this.initialized = true;
this.strings = document.getElementById("bs-strings");
var service = Components.classes["@mozilla.org/moz/jssubscript-loader;1"].getService(Components.interfaces.mozIJSSubScriptLoader);service.loadSubScript("chrome://global/content/writefunc.js");

},

我试图找到路径是我的扩展程序保存在Windows 7下但找不到它。我的猜测是Firefox和扩展程序在Windows 7下的安装方式不同,如果我像我一样声明路径,则无法找到该文件。有没有更好的方法来加载扩展名中的javascript文件?

1 个答案:

答案 0 :(得分:2)

writefunc.js是您或Firefox提供的文件?

如果由你,那么路径必须指向你的插件:

chrome://<yourAddonNameHere>/content/writefunc.js
相关问题