Reputation: 2077
I need one hidden iframe for all opened Firefox windows.
For now I'm creating iframe inside XUL overlay, so it is created for each browser window.
I think i should use XPCOM component to have single iframe instance for all browser windows, but i can't find way how to create XUL elements from it.
Is it possible?
Upvotes: 2
Views: 954
Reputation: 57651
You can create a frame inside the hidden window:
var hiddenWindow = Components.classes["@mozilla.org/appshell/appShellService;1"]
.getService(Components.interfaces.nsIAppShellService)
.hiddenDOMWindow;
var frame = hiddenWindow.document.getElementById("myExtensionFrame");
if (!frame)
{
var XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
frame = hiddenWindow.document.createElementNS(XUL_NS, "iframe");
frame.setAttribute("id", "myExtensionFrame");
frame.setAttribute("src", "...");
hiddenWindow.document.documentElement.appendChild(frame);
}
However, if all you need is a place to run your global code then there are better ways - like JavaScript code modules.
Upvotes: 3