xul way:
<toolbar id="PersonalToolbar">
<toolbarbutton
id="Testing-Doit-Button2"
class="bookmark-item pagerank"
tooltiptext="Do it!"
oncommand="testing_doit();"
/>
</toolbar>
javascript way:
function createBookmarkItem() {
const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
var item = document.createElementNS(XUL_NS, "toolbarbutton");
item.setAttribute("id", "Testing-Doit-Button2");
item.setAttribute("class", "bookmark-item pagerank");
item.setAttribute("tooltiptext", "Do it!");
item.setAttribute("oncommand", "testing_doit();");
return item;
}
function placeBookmarkItem() {
var toolbar = document.getElementById("PersonalToolbar");
var button = createBookmarkItem();
toolbar.appendChild(button);
}
placeBookmarkItem();
The xul way shows a button. The Javascript way shows a button when I go to the Javascript Shell of the Extension Developer's Extension, then click enumerateWindows(), then click chrome://browser/content/browser.xul, then type the code, then hit enter. The Javascript way doesn't show a button when I include button.js in button.xul. Why?