[Greasemonkey] Alternative to innerHTML?

Edward Lee edilee at gmail.com
Fri Jul 29 10:54:29 EDT 2005


On 7/29/05, Lenny Domnitser <ldrhcp at gmail.com> wrote:
> You're parsing an XML document--don't forget the namespace.
> 
> document.body.appendChild((new DOMParser()).parseFromString('<a
> xmlns="http://www.w3.org/1999/xhtml" href="."><b>H</b><i>i</i></a>',
> 'text/xml').childNodes[0])

Ooooh very nice. Works as expected. :) I tried the other suggestion of
importing nodes and that didn't seem to quite work.

And to the original question.. this does work fine with adding td elements.

document.getElementsByTagName('tr')[0].appendChild((new
DOMParser()).parseFromString('<td
xmlns="http://www.w3.org/1999/xhtml"><b>H</b><i>i</i></td>',
'text/xml').childNodes[0])

-- 
Ed


More information about the Greasemonkey mailing list