简体   繁体   English

Firefox扩展中的打开窗口事件

[英]Open window event in Firefox extension

I want to catch open in a new window events from my Firefox extension, but I couldn't find any event that can do this properly in my case. 我想从我的Firefox扩展中捕获一个新窗口中的事件,但是在我的情况下,我找不到任何可以正确执行此操作的事件。 I need this because I want to force an attachment content to download and to open in my PDF viewer extension. 我需要这样做是因为我想强制附件内容下载并在我的PDF查看器扩展中打开。 Is this possible? 这可能吗?

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM