Mozilla 浏览器退出观察者
我已经实现了“退出应用程序”观察者,
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 称为如下。
theApp.exitObserver = new theApp.ExitObserver();
observerService.addObserver(theApp.exitObserver, "quit-application", false);
当用户退出浏览器时,我的警报不起作用。这个实现有什么问题吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我建议首先简化您的代码。试试这个:
恐怕我无法在我的平台上测试这个,所以请原谅我的任何拼写错误。请让我知道您遇到了什么!
另请参阅此帖子。
I would suggest simplifying your code first. Try this:
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.