Internet Explorer has no problems with the length property. If it didn't support it, then it would report undefined
not 0
.
The HTML is invalid, there is no name
attribute for the div
element. Internet Explorer is just error recovering in a different way to Firefox and not matching the div elements with getElementsByName
Elements that support both the NAME attribute and the ID attribute are included in the collection returned by the getElementsByName method, but elements with a NAME expando are not included in the collection.
— MSDN getElementsByNameMethod
Use a class instead. Internet Explorer 8 doesn't have a native getElementsByClassName
, but there are no shortage of cross-browser implementations or you could use a selector engine or a big library that includes one such as YUI or jQuery.
, still got the same message.
– oYes Jul 19 '11 at 11:01