var mylib = { appendXulEl : function(parentId,nodeName,attribs){ var elem = document.getElementById(parentId); var node = document.createElement(nodeName); for (attrib in attribs) { node.setAttribute(attrib, attribs[attrib]); } elem.appendChild(node); } }
Usage:
mylib.appendXulEl('BrowserToolbarPalette', 'toolbarbutton', {'id':'MY_BUTTON_ID', 'label':'label for my button', 'tooltiptext':'button tooltip', 'class':'toolbarbutton-1', 'onclick':'alert("test")', 'context':''})