문제

I have implement "quit-application" Observer,

TestApp.ns(function() {
with (TestApp.Lib) {

    //Ci = Components.interfaces;

    theApp.ExitObserver = function() {},

    // Called on uninstall
    theApp.ExitObserver.prototype.observe = function(subject, topic, data){
        if (topic == "quit-application"){
            alert(" exit ");
        }

    };
    }
});

Im My Main.js file i called this ExitObserver as bellow.

theApp.exitObserver = new theApp.ExitObserver();
observerService.addObserver(theApp.exitObserver, "quit-application", false);

When user exit from browser my alert not working. Is there any issue in this implementation?

도움이 되었습니까?

해결책

I would suggest simplifying your code first. Try this:

var observerService = Components.classes["@mozilla.org/observer-service;1"]
                      .getService(Components.interfaces.nsIObserverService);
observerService.addObserver(
    {
        observe: function(subject, topic, data) {
            alert(topic);
        }
    }, "quit-application", false);

I'm afraid I can't test this on my platform, so forgive me for any typos. Please let me know what you run into!

See also this thread.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top