Get your own customer support community
 

Tips on dynamically adding HTML in XUL

The following code was more helpful to me for creating an inserting elements dynamically
It will be helpful if you cannot display your elements in the side bar
// create the top level html tag
var newElement = sidebarDoc.createElementNS('http://www.w3.org/1999/xhtml', 'html:a');
// create a href attribute
var href = sidebarDoc.createAttribute('href');
// assign value // anchorTags is the array of tags obtained (see Yasser's post)
href.nodeValue = anchorTags[i].href;
// set the attribute to the tag
newElement.setAttributeNode(href);

other useful js calls can be :
sidebarDoc.createTextNode(); // to create a plain text node ; the innerHTML property didnt work for me

also
anchorTags[i].innerText // will give you the text from the tags rather than HTML

Hope this helps
 
happy I’m confident
Inappropriate?
1 person likes this idea

User_default_medium