Skip to content Skip to sidebar Skip to footer

Creating A Xul Button Gives "component Failure Code"

I'm one of the developers of TryAgain, a Firefox add-on, that displays a custom error page when a website fails to load. It essentially replaces Firefox's netError.xhtml with a cus

Solution 1:

Remove the xul: from the name parameter of createElementNS.

Solution 2:

Using the XUL namespace has been deprecated. To my understanding, this means that it is no longer possible to place XUL and XHTML controls within a single XML document.

My solution was to instead use a normal XHTML <button> tag, and call it's onclick() listener by dispatching the event:

try {
    var evt = doc.createEvent('HTMLEvents');
    evt.initEvent('click', false, false);
    btn.dispatchEvent(evt);
} catch (e) {
    btn.click();
}

Why not just do btn.click() in the first place? I discovered some incompatibilities between using this method and add-ons that monitored clicking on the document. Dispatching the event directly circumvents this.

Post a Comment for "Creating A Xul Button Gives "component Failure Code""