On Nov 15, 2007 11:06 AM, Michael Vincent van Rantwijk, MultiZilla
<[EMAIL PROTECTED]> wrote:
> > //register Observer
> > window.addEventListener("load", MyObserver, false);
> > function MyObserver(){
> > var observerService = Components.classes["@mozilla.org/observer-service;1"]
> > .getService(Components.interfaces.nsIObserverService);
>
> Don't do that here, but outside the observer; because it will 'run' for
> all loads!
>
Huh?
> > 1. how can i find that observer is registered before or not ?
>
> Have you looked at enumerateObservers in nsIObserverService.idl already?
>
Oops. Still you shouldn't use it, at least in your case. (I question
the kosherness of its in-tree uses).
> > 2. when i register observer only when first window opens every thing
> > is ok, when i open some other windows still every thing is ok and
> > observer
> > works perfectly, but when i close first window while other windows are
> > still
> > open the observer doesn't work anymore ?!
>
> There is a hidden window which you can use, or better use a (JavaScript)
> component to store your global vars and observers, which makes listening
> for opening and closing of (browser) windows also a lot easier.
>
Can we stop suggesting people use the hidden window? It's an
implementation detail really, not to be used by extensions.
Nickolay
_______________________________________________
Project_owners mailing list
[email protected]
https://www.mozdev.org/mailman/listinfo/project_owners