I want to setup label
attributes, and event listeners for a toolbaritem
when it's being used. Because even though I add my extension's toolbaritem
to <toolbarpalette id="BrowserToolbarPalette">
it is not found by document.getElementById
unless it is being used. At the moment I have DOMNodeInserted
event listeners on the navigation bar and add-on bar which sets up my toolbaritem
's attributes, but I'm wondering if there is a better way?
Asked
Active
Viewed 116 times
0
2 Answers
-1
Are you calling document.getElementById
too early, possibly before Firefox has added the item into the toolbar? If so, you might want to move your code to a function which is registered to be called on the "load"
event on the main browser window. This should ensure that the browser, including the toolbar, has been successfully built by the time your code runs.

Tim
- 9,171
- 33
- 51
-
The document.getElementById call is in a "load" event listener, the item dne and this appears to be because the user needs to customize the toolbar and add it. – erikvold Oct 22 '10 at 18:38
-2
Have a look at Broadcasters and Observers. I think this will help you.

Felix Kling
- 795,719
- 175
- 1,089
- 1,143
-
I just read it, it doesn't appear to be helpful. It appears to describe how you can broadcast changes to multiple elements in a document, but I want to know when a toolbaritem is added to browser.xul, which seems to me to be a completely different problem. – erikvold Oct 23 '10 at 19:39
-
@Erik Vold: What event listeners do you want to add to the button? You said *which sets up my toolbaritem's attributes*. You could have the attributes and event handlers set on the broadcaster instead and let the toolbarbutton observe them. – Felix Kling Nov 24 '10 at 20:03
-
Thanks Felix, this is a better way to solve my problem for now, but doesn't answer my question. – erikvold Dec 04 '10 at 23:25
-
-