Kyle aber hob zu reden an und schrieb:
> I'm writing a chrome extension that currently creates an instance of
> an object when an overlay is loaded. This currently means that a new
> instance is created for every window that contains the overlay.
>
> I would prefer to be able to create a single instance of the object
> when the Mozilla starts, and make reference to this instance when
> other windows are created. This also means that I would like to keep
> the instance alive after the overlay that created it has been
> destroyed.
You could attach your custom object to the global hidden window:
if (!("yourGlobalObject" in this))
{
var oAppShell =
Components.classes['@mozilla.org/appshell/appShellService;1']
.getService(Components.interfaces.nsIAppShellService);
var oHiddenWindow = oAppShell.hiddenDOMWindow;
if (oHiddenWindow)
{
oHiddenWindow.yourGlobalObject = { ... };
this.yourGlobalObject = oHiddenWindow.yourGlobalObject;
}
}
if ("yourGlobalObject" in this)
{
// use this.yourGlobalObject to access your global object
}
You'd call this script in every overlay.
Karsten
--
Freiheit stirbt | Fsayannes SF&F-Bibliothek:
Mit Sicherheit | http://fsayanne.tprac.de/
_______________________________________________
Mozilla-xpcom mailing list
[EMAIL PROTECTED]
http://mail.mozilla.org/listinfo/mozilla-xpcom