【发布时间】:2011-07-25 11:30:10
【问题描述】:
我有以下 js 对象:
var livePage = {
delay: 1000,
loadTables: function(){
loadTable($("#vbeTable"),'getUpdateA')
loadTable($("#vbcTable"),'getUpdateB')
createAlertDialog();
},
setClicks: function(){
$(".expand").live('click',function(){
expand($(this).attr('expandvalue'));
})
$( ".launch" )
.click(function(){
newPopup('index.php',1120,550);
});
$('.edit').live('click',function(){
openColPick($(this).attr('colType'))
});
},
setRightClick: function(){
$('body').contextMenu('mainmenu', {
bindings: {
'o_o': function(t) {
thePopupWindowsMain('oo','','',220,150,'right','');
},
'o_h': function(t) {
thePopupWindowsMain('oh','','',285,385,'left','');
},
'launch_prog': function(t) {
$(".launch").click();
},
'logout': function(t){
window.top.location = 'logout.php';
}
}
});
},
setWindow: function(){
$(window)
.resize(function() {
$('body').css('height', $(this).height())
alertToCorner();
})
.scroll(function(){$(this).resize()});
$(window).resize();
},
checkLogout: function(){
$.ajax({
url: 'getLogin.php',
dataType: "html",
success: function(data){
if($.trim(data) == 'LOGOUT'){
window.location = 'logout.php';
}
},
complete: function(){
setTimeout( function () {
livePage.checkLogout();},
livePage.delay)
},
timeout: 2000
});
},
init: function(){
this.checkLogout();
this.loadTables();
this.setClicks();
this.setRightClick();
this.setWindow();
console.log(this);
}
}
由于某种原因在checkLogout: function() 中我必须使用livePage.delay 和livePage.checkLogout() 当我尝试使用例如this.checklogout() 时,我在Chrome 的控制台中收到以下错误:
未捕获的类型错误:对象 [对象 DOMWindow] 没有方法'checkLogout'
我该如何解决这个问题?
谢谢!
【问题讨论】:
标签: javascript jquery object this