How to create a XUL toolbar through Javascript?

With the advent of multiprocessor Firefox, I decided to overwrite my addon using Addon-SDK.

My addon is basically a toolbar with a wide range of menus.

addonsdk provides no way to create a menu. So, I found this method with which I can add them to an existing toolbar. However, I cannot find a way to create such menus and add them to the Addon-SDK toolbar. So I thought I was just creating a toolbar the same way I was creating a menu.

So, I'm basically trying to create an XUL toolbar through javascript (I think):

var MyDelegate = {
    onTrack: function(window){
        //don't add this to other windows, just the browser window
        if(window.location != "chrome://browser/content/browser.xul") {
            // console.log("=> win location false");
            return;
        }
        var document = window.document; //we need this to attach the XUL elements

        var MyBar = window.document.createElement('toolbar');
        MyBar.setAttribute('id', 'MyToolbarID');
        MyBar.setAttribute('toolbarname', 'MyTitle');
        MyBar.setAttribute('class', 'chromeclass-toolbar');
        MyBar.setAttribute('mode', 'full');     
        MyBar.setAttribute('hidden', 'false');      
        MyBar.setAttribute('insertafter', 'PersonalToolbar');   
    }
}
let utils = require('sdk/deprecated/window-utils'); // for new style sdk
utils.WindowTracker(spatDelegate);

What do I need to do to make this toolbar really create and display in the browser?

[update]

, SDK, , async , html id. html- , .

0
1

MyBar :

window.document.getElementById("navigator-toolbox").appendChild(MyBar);
+1

All Articles