I have to use a picture, Stackoverflow says:
Oops! Your question couldn't be submitted because: Your post appears to contain code that is not properly formatted as code. Please indent all code by 4 spaces using the code toolbar button or the CTRL+K keyboard shortcut. For more editing help, click the [?] toolbar icon.
The screenshot was taken from Stackoverflow's form.
I have to use a picture, Stackoverflow says:
Oops! Your question couldn't be submitted because: Your post appears to contain code that is not properly formatted as code. Please indent all code by 4 spaces using the code toolbar button or the CTRL+K keyboard shortcut. For more editing help, click the [?] toolbar icon.
The screenshot was taken from Stackoverflow's form.
Share Improve this question asked Jul 19, 2011 at 10:56 oYesoYes 732 silver badges9 bronze badges 2- 3 On different note, why don't you just indent the code as instructed. – Shamim Hafiz - MSFT Commented Jul 19, 2011 at 11:00
- I did indent the code.. infact.. I don't use <code>, still got the same message. – oYes Commented Jul 19, 2011 at 11:01
3 Answers
Reset to default 8Internet 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.
getElementsByName
is for use on input
HTML elements - DIV elements do not have name
attributes
Your problem is not that .length is not working on IE, but that getElementByName() is not working on IE... : getElementsByName in IE7