Connecting Tech Pros Worldwide Help | Site Map

add a method to object HTMLCollection

  #1  
Old May 10th, 2006, 11:25 PM
Grzegorz ¦lusarek
Guest
 
Posts: n/a
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
  #2  
Old May 18th, 2006, 01:45 PM
Thomas 'PointedEars' Lahn
Guest
 
Posts: n/a

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to extend document.getElementsBy*() in Firefox Dormilich answers 11 June 18th, 2009 09:14 AM
Extend HTMLCollection.prototype with Firefox? Matt Kruse answers 7 February 5th, 2007 12:35 AM
Add New Line juicy answers 3 April 4th, 2006 07:15 AM
Attach event/function to links within span tag johkar answers 26 January 24th, 2006 07:25 AM