Javascript错误,无法识别函数.为什么
Javascript error, not recognizing function... why?
这是我的代码(在firefox插件中)
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("parasites@maafire.com", 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("parasites@maafire.com");
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);
}
我得到错误:
错误:这个。Get_plugin_version不是一个函数源文件:chrome://mf_monkey_project/content/overlay.js行:476
我做错了什么?
对不起,我把格式搞砸了,但是我删除了大量的代码来适应这里,这使得格式都很混乱。
因为setTimeout
回调将在全局上下文中执行。
你可以使用bind()
[docs]方法来绑定回调所需的上下文和参数。
this.timervar=setTimeout( this.get_plugin_version.bind(this, this.this_version),
2000 );
如果您不希望this.this_version
的当前值永久绑定为第一个参数,则从.bind()
调用中删除它。
相关文章:
- 无法识别从php创建的Js函数
- 函数无法识别初始化的变量
- jQuery选择器不识别任何动态创建的HTML输入函数
- PHP函数识别3个数字中最低的一个并更改其类
- 如何在javascript中识别函数的参数名称
- Jslint 无法识别错误排序函数的选项
- angular/javascript无法识别函数内部的全局变量
- 如何在Javascript(或Node)中识别函数的参数
- Javascript 无法识别函数中的变量
- InnerHTML onclick无法识别函数
- Chrome无法正确识别函数参数
- 如何识别函数是作为方法调用还是作为回调调用
- AngularJS无法识别函数
- JQuery,操作无法识别函数内部的变量
- Javascript-当使用createElement的东西调用js文件时,无法识别函数
- javascript setTimeout不能识别函数参数
- 在javascript中通过指针识别函数
- 使用Gulp时无法识别函数
- Javascript错误,无法识别函数.为什么
- 识别函数javascript的元素