[Greasemonkey] Re: Greasemonkey Digest, Vol 5, Issue 91

Matt Labrum darktempler at gmail.com
Sat Apr 23 04:39:44 EDT 2005


---------- Forwarded message ----------
From: Prakash Kailasa <pk-moz at kailasa.net>
To: greasemonkey at mozdev.org
Date: Fri, 22 Apr 2005 13:29:04 -0400
Subject: Re: [Greasemonkey] document.replaceChild
On Sat, Apr 23, 2005 at 02:54:15AM +0930, Matt Labrum wrote:
>> Im trying to write a script to replace the textarea of a site with
>> another element but I cant seem to get document.replaceChild to do it.
>>
>> the Javascript im using is
>>
>> var textarea = document.getElementsByTagName("textarea")[0];
>> var newnode = document.createElement("p");
>> newnode.innerHTML = "TEST";
>> document.replaceChild(newnode, textarea);

>replaceChild method should be called on the parent node, not on the
document node >(unless the node being replaced is the direct child of
the document node).

>Try this instead:

>textarea.parentNode.replaceChild(newnode, textarea);

>HTH,
>/prakash

Thanks man that worked :) and I've learnt something new :D


More information about the Greasemonkey mailing list