Discussion:
specifying a specific tab when executing code in an add-on
mike durakovich
2010-03-22 16:13:21 UTC
Permalink
I am creating an add-on that has an issue of focus. If I have
multiple tabs running in parallel that all trigger the add-on
simultaneously on load, all the code will be executed against the tab
that has focus.

Using the following to listen for the page load:

gBrowser.addEventListener("DOMContentLoaded", function(aEvent)
{always(aEvent);}, false);

So, the issue is that the code is being triggered on a tab load, but
isn't executing in the calling tab, just the tab with focus. How can
I specify a particular tab of unknown index to execute the code in,
regardless if that tab has focus or not?
johnjbarton
2010-03-22 16:26:32 UTC
Permalink
Post by mike durakovich
I am creating an add-on that has an issue of focus. If I have
multiple tabs running in parallel that all trigger the add-on
simultaneously on load, all the code will be executed against the tab
that has focus.
gBrowser.addEventListener("DOMContentLoaded", function(aEvent)
{always(aEvent);}, false);
So, the issue is that the code is being triggered on a tab load, but
isn't executing in the calling tab, just the tab with focus. How can
I specify a particular tab of unknown index to execute the code in,
regardless if that tab has focus or not?
For FF 3.7, you can use content-document-global-created event from Bug
549539.

In Firebug we use onLocationChange events and we try to avoid dealing
with tabs if possible.

jjb
mike durakovich
2010-03-22 22:22:56 UTC
Permalink
Post by johnjbarton
I am creating an add-on that has an issue of focus.  If I have
multiple tabs running in parallel that all trigger the add-on
simultaneously on load, all the code will be executed against the tab
that has focus.
gBrowser.addEventListener("DOMContentLoaded", function(aEvent)
{always(aEvent);}, false);
So, the issue is that the code is being triggered on a tab load, but
isn't executing in the calling tab, just the tab with focus.  How can
I specify a particular tab of unknown index to execute the code in,
regardless if that tab has focus or not?
For FF 3.7, you can use content-document-global-created event from Bug
549539.
In Firebug we use onLocationChange events and we try to avoid dealing
with tabs if possible.
jjb
Thanks, but I need it to be effective prior to 3.7. Think I got the
answer in a different thread, which was to reference aEvent.target in
lieu of content.document, which seems to be working as needed.

Loading...