2014-10-09 91 views
0

我試圖維護一個Firefox擴展,它依靠獲取當前的內部窗口標識。在Firefox 31的窗口對象有一個QueryInterface:在Firefox 32擴展中獲取當前內部窗口標識

components/foo.js: 

Foo.prototype = { 
    window: null, 
    ... 
    init: function(aWindow) { 
    this.window = XPCNativeWrapper.unwrap(aWindow); 
    var util = this.window.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils); 
    dump('Your inner window ID is: ' + util.currentInnerWindowID + '\n'); 
    }, 
    ... 
    shutdown: function() { 
    } 
} 

在Firefox 32中window.QueryInterface對象已經消失,我想知道如何得到當前內窗口ID。

謝謝。

回答

0

調用XPCNativeWrapper.unwrap從aWindow中刪除QueryInterface。

if (aWindow.QueryInterface) { 
    util = XPCNativeWrapper.unwrap(aWindow.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils)); 
    dump('Your inner window ID is: ' + util.currentInnerWindowID + '\n'); 
} 
相關問題