I am working on a Firefox addon and now I need to dynamically add menu items to the menupopup element. I tried basically all approaches to the Mozilla Developer Center, and none of them work.
function populateDropdown() {
var counter = 0;
for (var key in services) {
var newMenuItem = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "menuitem");
newMenuItem.setAttribute("label", services[key]['title'])
document.getElementById("mainDropdown").appendChild(newMenuItem);
}
}
This code breaks into the appendChild command. Any ideas why?
source
share