我想在我的Firefox扩展程序的新窗口中打开事件,但在我的情况下,我找不到任何可以正常执行此操作的事件。我需要这个,因为我想强制下载附件内容并在我的PDF查看器扩展中打开。这可能吗?
答案 0 :(得分:0)
var windowListener = {
onOpenWindow: function (aXULWindow) {
// Wait for the window to finish loading
var aDOMWindow = aXULWindow.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowInternal || Ci.nsIDOMWindow);
aDOMWindow.addEventListener("load", function () {
aDOMWindow.removeEventListener("load", arguments.callee, false); //this removes this load function from the window
//play with your window here
}, false);
},
onCloseWindow: function (aXULWindow) {},
onWindowTitleChange: function (aXULWindow, aTitle) {}
};
//to register
Services.wm.addListener(windowListener);
//Services.wm.removeListener(windowListener); //do this to remove