以下のコードが出力されます。
timedout false undefined
つまりin methodをthis
参照しなくなりました。これはなぜだろうと思いました。theActivityTimer
timedOut()
var theActivityTimer = {
timer: "",
active: false,
refresh: function () {
theActivityTimer.timer = setTimeout(
this.timedOut,
5000
);
},
timedOut: function(){
alert("timedout " +
theActivityTimer.active + " " + this.active);
}
}
theActivityTimer.refresh();
http://jsfiddle.net/spiderplant0/nQ4XX/
そして、それを動作させるように指示する方法はありますかthis