By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
460,034 Members | 1,247 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 460,034 IT Pros & Developers. It's quick & easy.

emulate removechild in IE 4?

P: n/a
How can I emulate DOM level 1 removeChild in IE 4? I already figured
out to emulate getElementById by doing this

if((!document.getElementById) && document.all)
{document.getElementById = function(id){return document.all[id];};
}

Is there something similar for removeChild?

Jul 23 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
On 31 Dec 2004 12:25:09 -0800, <bu****@hotmail.com> wrote:
How can I emulate DOM level 1 removeChild in IE 4?
With enormous difficulty.
I already figured out to emulate getElementById by doing this

if((!document.getElementById) && document.all)
{document.getElementById = function(id){return document.all[id];};
}
That's an approximation as the all collection will return elements that
match by either id or name, and if there is more than one result a
collection, rather than a single reference, will be returned. Be aware of
that when you're producing your mark-up so that you will only every get
one reference. Alternatively, see the second example at
<URL:http://www.jibbering.com/faq/faq_notes/not_browser_detect.html#bdGEID>.
Is there something similar for removeChild?


You might be able to use the innerHTML property to remove the element,
though that would depend on the parent element in question (IE4 doesn't
implement innerHTML on all elements).

Good luck,
Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 23 '05 #2

P: n/a


bu****@hotmail.com wrote:
How can I emulate DOM level 1 removeChild in IE 4?


Well IE 4 doesn't know text nodes for instance so you can't write a
method for all types of child nodes that exist in DOM Level 1.
If you have an element node (e.g. accessed with
element.children[0]
) then you can simply set outerHTML to an empty string
if (element.children && element.children[0]) {
element.children[0].outerHTML = '';
}

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.