[Greasemonkey] a little help?

chris feldmann cfeldmann at gmail.com
Sun Sep 25 13:41:55 EDT 2005


On 9/25/05, Bill Donnelly <donnelly at snowcrest.net> wrote:
> What is the easiest way to insert the html below into
> an html document via a script?
>
> Do you have to create every tag individually with the
> createElement() and appendChild() methods and then use
> insertBefore() and .nextSibling with the final result?
>
> Or can you set .innerHTML to the whole text block value for
> a single created element that you can insertBefore()?
>
> <div style="margin: 0px;">
> <div align="left" style="height: 0px; width: 100%;">
> <div align="center" style="border-style: none ridge ridge;">
> <span style="font-family: Arial,Helvetica,Sans-serif;">
> Text</span>
> </div>
> </div>
> </div>

Personally, I'd create a documentFragment and, yes, createElement(),
createTextNode() and appendChild() the rest to it, then append the
fragment. And append the style elements through createElement("style")
and appending it to the head through getElementsByTagName("head")[0]
(a technique that can be found in diveintogreasemonkey.org). But you
know about ppk's innerHTML "benchmark," right?
http://www.quirksmode.org/dom/innerhtml.html



>
> TIA
>
> --
> Not all who wander are aimless.
> ---------------------------------
> Some of us Drink Deeply from
> the Fountain of Knowledge.
> Most people sip; too many gargle.
> ---------------------------------
> I just ate your Soul.
> Forgive me. It was juicy.
> And tart on my tongue.
>
> _______________________________________________
> Greasemonkey mailing list
> Greasemonkey at mozdev.org
> http://mozdev.org/mailman/listinfo/greasemonkey
>


More information about the Greasemonkey mailing list