[Greasemonkey] Alternative to innerHTML?

Edward Lee edilee at gmail.com
Thu Jul 28 19:16:30 EDT 2005

You can try playing around with DOMParser.. but that only parses correct xml.

The DOMParser object has a function parseFromString that returns an
XMLDocument.. and its child is an Element Object.. which doesn't seem
to want to be a html thing ;)

document.body.appendChild((new DOMParser()).parseFromString('<a
href="."><b>H</b><i>i</i></a>', 'text/xml').childNodes[0])

It does indeed add the text.. but no styling of the anchor, bold, italics.

Another method is to stick the html into an iframe (doesn't even have
to be xhtml!) and get the nodes created from the iframe.


More information about the Greasemonkey mailing list