Reputation: 14920
From a Firefox extension is there a way to get the XUL iframe/browser that contains a content HTML window. Note I am not asking how to get the current browser (gBrowser) or the browser.xul window. I have target/content HTML window handle, I want to follow it up in the XUL tree (to the XUL element that contains it).
getting-a-reference-to-the-parent-iframe suggest that for HTML iframes you need to iterate through all iframes to find the right one, but I am wondering if there is some Firefox-specific way of accessing a containing XUL iframe (from privileged/extension code).
Upvotes: 1
Views: 1508
Reputation: 55422
aWindow.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIWebNavigation)
.QueryInterface(Components.interfaces.nsIDocShell)
.chromeEventHandler
Note that in Firefox 3.6 and previously this returns an XPCNativeWrapper which you then probably want to unwrap.
Upvotes: 2
Reputation: 9512
From an extension's point of view, "window" is the top level chrome window of Firefox, containing special <vbox> and <hbox> elements for the buttons, toolbars, etc. You can see these in the DOM Inspector if you go to File -> Inspect Chrome Document -> (Browser Window). To get the current page frame from extension's Javascript, use content.
To get the outer window, use window.parent, or window.parent.top. If the inner document is chrome-privileged, perhaps you could check for a special attribute or variable at the window level.
Upvotes: 0
Reputation: 57691
In an extension your code is typically already executing in the main window, so you simply use gBrowser
(see https://developer.mozilla.org/en/Code_snippets/Tabbed_browser#From_main_window).
If your code runs in a different window then window mediator is your friend: https://developer.mozilla.org/en/Code_snippets/Tabbed_browser#From_a_dialog
Upvotes: 0