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 the开发者_运维技巧re is a better way?
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.
Have a look at Broadcasters and Observers. I think this will help you.
精彩评论