add a method to object HTMLCollection

  • Thread starter Grzegorz ¦lusarek
  • Start date
G

Grzegorz ¦lusarek

Hi all. Is it posible to add a method to prototype of object HTMLCollection?
I mean something like this:
HTMLCollection.prototype.indexOf=function(obj){
var result=-1;
for (var i=0;i<this.length;i++){
if (this==obj){
result=i;
break;
}
}
return result;
}

my trials fail for now but I will try more
thanks for any help
Gregor
 
T

Thomas 'PointedEars' Lahn

Grzegorz said:
Hi all. Is it posible to add a method to prototype of object
HTMLCollection?
I mean something like this:
HTMLCollection.prototype.indexOf=function(obj){
var result=-1;
for (var i=0;i<this.length;i++){
if (this==obj){
result=i;
break;
}
}
return result;
}


Yes, it is, in the Gecko DOM. However, this does not have an effect on
DOM collections like document.forms or those retrieved with
document.getElementsByTagName() etc. yet: the respective objects do not
inherit from HTMLCollection. It does work for HTMLOptionsCollection,
though.
my trials fail for now

"Does not work" is a useless error description. [psf 4.11]

<URL:http://jibbering.com/faq/#FAQ4_43>


PointedEars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,430
Messages
2,571,676
Members
48,796
Latest member
Greg L.

Latest Threads

Top