Connecting Tech Pros Worldwide Forums | Help | Site Map

add a method to object HTMLCollection

Grzegorz ¦lusarek
Guest
 
Posts: n/a
#1: May 10 '06
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[i]==obj){
result=i;
break;
}
}
return result;
}

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

Thomas 'PointedEars' Lahn
Guest
 
Posts: n/a
#2: May 18 '06

re: add a method to object HTMLCollection


Grzegorz Ĺšlusarek wrote:
[color=blue]
> 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[i]==obj){
> result=i;
> break;
> }
> }
> return result;
> }[/color]

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.
[color=blue]
> my trials fail for now[/color]

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

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


PointedEars
--
What one man can invent another can discover.
-- Sherlock Holmes in Sir Arthur Conan Doyle's
"The Adventure of the Dancing Men"
Closed Thread