Firefox addon Mozilla浏览器退出观察者
我已经实现了“退出应用程序”观察器Firefox addon Mozilla浏览器退出观察者,firefox-addon,mozilla,add-on,Firefox Addon,Mozilla,Add On,我已经实现了“退出应用程序”观察器 TestApp.ns(function() { with (TestApp.Lib) { //Ci = Components.interfaces; theApp.ExitObserver = function() {}, // Called on uninstall theApp.ExitObserver.prototype.observe = function(subject, topic, data){
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 ");
}
};
}
});
我是我的Main.js文件,我把这个ExitObserver称为bellow
theApp.exitObserver = new theApp.ExitObserver();
observerService.addObserver(theApp.exitObserver, "quit-application", false);
当用户退出浏览器时,我的警报不工作。这个实现中有什么问题吗?我建议先简化代码。试试这个:
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);
恐怕我不能在我的平台上测试这个,所以请原谅我的错误。请告诉我你遇到了什么
另请参见。您确定正在添加您的观察者吗?