XUL button is not displayed

I am 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 netError.xhtmlwith an individual version.

However, I ran into some problems with terminal compatibility between 3.0. * - 3.6. * and Fx4b5. (The entry in netError.dtd has been renamed, causing an XML parsing error in both one and the other version.)

To fix this, I decided that the extension dynamically changes the page, as opposed to completely replacing it. One of the elements that I need to add to netError.xhtmlin Fx3 is <xul:button>. However, adding it with the following code, nothing is displayed on the screen:

var div = document.getElementById("errorContent");
var btn = document.createElement("xul:button");
btn.setAttribute("label", "Hello world");
btn.setAttribute("oncommand", "alert('Hello world!');");
div.appendChild(btn);

I see that in the Mozilla Developer Center there is this note :

Gecko's createElement implementation does not comply with the DOM specification for XUL and XHTML documents: localName and namespaceURI are not null for the created element. See error 280692 for more details .

What does this mean and how can I solve it?

Also, how can I execute the event oncommandthrough JavaScript?

+3
source share
1 answer

document.createElement() . "xul: button", , "xul: button" (== its localName), XUL "button".

, XML < xul: button > : , xul ( xmlns:xul="" ) "button" .

DOM XUL (X) HTML , document.createElement("buttton") XUL HTML XUL HTML .

:

var XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
document.createElementNS(XUL_NS, "button")

, - :

document.createElementNS(XUL_NS, "xul:button")
+1

Source: https://habr.com/ru/post/1764456/


All Articles