Firefox (3.6. *) 용 애드온을 개발 중입니다. 다음 코드 notify
에서 내부에서 호출 된 init
이 제대로 작동하지만 onPageLoad
에서 호출하면 this.notify is not a function
이라고 말하는 오류가 발생합니다. 왜 그런가요?Firefox 부가 기능 - 하나의 메소드에서 작동하지만 동일한 객체의 다른 메소드에서 실패 함
myextobj.notify('title', 'msg')
으로 전화를 변경하면 작동합니다. 변수 액세스에 대해서도 마찬가지입니다. 그렇다면 this
과 개체 이름의 접두사의 차이점은 무엇입니까?
var myextobj = {
init: function() {
this.notify('init', 'We are inside init');
...
var appcontent = document.getElementById("appcontent"); // browser
if(appcontent)
appcontent.addEventListener("DOMContentLoaded", this.onPageLoad, true);
},
onPageLoad: function(aEvent) {
this.notify('onPageLoad', 'We are inside onPageLoad');
...
},
notify: function (title, text) {
Components.classes['@mozilla.org/alerts-service;1'].
getService(Components.interfaces.nsIAlertsService).
showAlertNotification(null, title, text, false, '', null);
}
};
window.addEventListener("load", function() { myextobj.init(); }, false);