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
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
1
person likes this idea
I like this idea!
Tell me when this idea gets some attention.
The more people who like this idea, the more it gets noticed.
The more people who like this idea, the more it gets noticed.
Create a customer community for your own organization
Plans starting at $19/month
-
Inappropriate?Thanks Ullas for your hints!
Loading Profile...



EMPLOYEE