
insertAdjacentHTML and removeChild
NN6 has similar features:
<DIV ID="mydiv">...</DIV>
is scripted as
var mydiv = document.getElementById('mydiv');
You can then navigate the document subtree with
mydiv.nextSibling
mydiv.previousSibling
mydiv.firstChild
mydiv.lastChild
mydiv.childNodes
e.g.
mydiv.removeChild(mydiv.lastChild)
To insert HTML in the document tree you need to parse it first into a
document fragment:
var range = document.createRange();
range.setStartAfter(mydiv.lastChild);
var documentFragment = range.createContextualFragment(htmlstring));
which you can then insert into the document tree
mydiv.appendChild(documentFragment);
To check for the existence of an IDed element you check
var el;
if ((el = document.getElementById('elementID'))
// script el
Quote:
> Hi folks
> Do Netscape and other browsers support
> mydiv.insertAdjacentHTML("BeforeEnd",htmltagstring) and also
> childelement = mydiv.children(nameofelement)
> mydiv.removechild(childelement)
> Also, using
> if (window[someelementname])
> to check existence of element
> I use these to dynamically add/remove html
> Thanks and Season's Greetings.........
> Justin Dutoit
> PS Do you have to say document. before referencing an element in Netscape?
> In caps? I'm looking for a reference.... Ta
--
Martin Honnen
http://javascript.faqts.com/
http://home.t-online.de/home/martin.honnen/jsgoddies.html