开发者

What's the best way to be notified when an extension's toolbaritem is being used?

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜