WebFX WebBoard
Message Thread:
View All Messages
Back to WebFX
 new methods to natives objects, dreadcast, June 10, 2004
     Re:new methods to natives objects, Brian R. James, June 22, 2004
         Re:new methods to natives objects, dreadcast, July 8, 2004
             Re:new methods to natives objects, Erik Arvidsson, July 19, 2004
                 Re:new methods to natives objects, dreadcast, July 25, 2004

Subject: Re:new methods to natives objects From: Brian R. James Date: June 22, 2004

Check out this article at AlphaFilter()  http://www.alphafilter.com/go.foo/article/?aid=88/ 

From: dreadcast
Sent: June 10, 2004
Subject: Re:new methods to natives objects

Hello,
I am desesperatly looking for a way to define new methods to the natives javascript objects in IE.
ex :

function _getElementsByClassName (sClassName) {
 var elements = Array();
 if(document.all) el = document.all;
 else el = this.getElementsByTagName('*');
 for (i = 0; i < el.length; i++) if (el[i].className == sClassName) elements.push(el[i]);
 return elements;
}
Object.prototype.getElementsByClassName = _getElementsByClassName;

This allows me to get every elements whose class name is sClassName from any element in the document :

<body onload="alert(document.getElementById('kj').getElementsByClassName('test'));">
<div id="kj">
 <div class="test"></div>
 <div class="test"></div>
 <div class="test"></div>
</div>
</body>


This works properly in mozilla, but IE returns (I don't know the exact message in english) this object doesn't have this method or this property

Thanks in advance for helping !





Reply
Name: 
Email: 
Subject: 

Enter your reply to this message below. HTML tags are not supported but words that start with http://, ftp:// or mailto: are converted to links.


View All Messages
Back to WebFX