Custom function for element addition
Posted: Thu May 14, 2009 4:51 am
Hiya, i'm trying to add in a function to insert an child node in front of all child nodes, below is how far i've gotten:
This works perfectly in firefox, but in IE I get the classic "interface is not supported" when it gets to the "this.insertBefore" part. If you have any suggestions i'd love to hear them!
Cheers!
Darkzaelus
Code: Select all
Object.prototype.insertFirst=function(obj) {
if(this.nodeType!==undefined&&this.childNodes!==undefined) {
if(this.childNodes.length==0)
this.appendChild(obj);
else this.insertBefore(obj, this.firstChild);
}
}Cheers!
Darkzaelus