0
这是我的代码(在一个Firefox插件)Javascript错误,不承认功能...为什么?
this.something_something = function (the_actual_url) {
this.this_version = null;
try {
// Firefox 4 and later; Mozilla 2 and later
Components.utils.import("resource://gre/modules/AddonManager.jsm");
AddonManager.getAddonByID("[email protected]", function (addon) {
this_version = addon.version;
});
}
catch (ex) {
// Firefox 3.6 and before; Mozilla 1.9.2 and before
var em = Components.classes["@mozilla.org/extensions/manager;1"].getService(Components.interfaces.nsIExtensionManager);
var addon = em.getItemForID("[email protected]");
this_version = addon.version;
}
this.timervar = setTimeout(function() {
this.get_plugin_version(this.this_version);
}, 2000);
}
this.get_plugin_version = function (blah) {
alert("aa:" + blah);
}
我得到的错误:
Error: this.get_plugin_version is not a function Source File: chrome://mf_monkey_project/content/overlay.js Line: 476
我在做什么错?
对不起,搞砸了格式化,但我删除了大部分的代码,以适应在这里,它使格式化全部扭曲。
现在我得到'错误:this.get_plugin_version未定义 源文件:铬://mf_monkey_project/content/overlay.js 行:476' – Ryan
@Ryan:然后'this'在'something_something'功能不你期望的对象。 – user113716
哎呀,不,我做了一个编辑,而不是复制你的代码..它的工作原理,但给我null作为版本号:(任何想法为什么? – Ryan