getElementsByClassName has changed
- Published March 26th, 2008 in Web/W3C
Both Safari 3.1 and Firefox 3 Beta 4 have heavily changed the DOM method getElementsByClassName to reflect W3C specifications. Therefore, there’s a strong chance that you’ll have a couple of users complaining in case you’re using this method.
To overcome this your best bet is probably relying on a high level select function like the one provided in Prototype or in jQuery’s select.




They didn’t change the method… they (apple+mozilla) simply implemented it. It was Prototype that wrongly implemented document.getElementsByClassName (ahead of time) that lead to developers using the returned object, which was filled with Prototype specific functions, to use it in a non-w3c way.
document.getElementsByClassName(’blabla’).each( function (el) { … } );
This is the top reasons why I strongly dislike Prototype’s meddling in the global scope of the DOM… bah.
Resig, pointed this out very recently: http://ejohn.org/blog/getelementsbyclassname-pre-prototype-16/
(he can because he avoid this in jquery elegantly).
Thanks for the excellent insights on this issue André.