1
我有一个关于我正在处理的一段JavaScript代码的问题。在另一个关于stackoverflow的问题上,我读过,你可以在method2里面做一个this.method1。但是,当这样做'this'指向当前窗口对象和方法1(自然)无法找到。'this'里面的函数
请告诉我如何最好地解决这个问题。
我得到的错误是:
TypeError: this.initFB is not a function
this.initFB();
代码:
var FPPL = {
/** Variables */
larvaunched : false,
/**
*
*/
initFB : function(){
if ((typeof(FB)!= 'undefined')) {
FB.init({
xfbml: true,
status : true, // check login status
cookie : true // enable cookies to allow the server to access the session
});
}
},
initCode : function(){
console.log(this);
this.initFB();
if (!this.checkForLaunch())
return false;
window.setTimeout(this.showFaceBox, lb_l_ret.delay);
}
....
}
window.fbAsyncInit = FPPL.initCode;
也许这initCode点发挥作用initCode – MrOnlineCoder