Site Navigation

Tuesday, September 25, 2007

bug 154 - getElementById is NOT case sensitive in IE

Issue: #154
Affects: IE6, IE7
Fixed In: IE8

MSIE Feedback ID: 333979

"Just when you thought it was safe to go back in the water"! (credit to JAWS the movie) IE's getElementById( id ) throws another curve ball!

Although it should be according to the (spec), IE performs a case-insensitive search for IDs. This isn't likely as bad as (bug 152), but still a concern, if you have 2 IDs with different cases.

Example:

<form id="userInfo">
<input id="userid" value="grovermonster"/>
<input id="userfirst" value="Grover"/>
<input id="userlast" value="Monster"/>
<textarea id="userinfo">
Cute and cuddly and Blue!
</textarea>
<form>
<script type="text/javascript">
var infoForUser = document.getElementById('userinfo').value;
alert('Info for this user:\n\n' + infoForUser);
</script>


In IE, this won't return the "Cute and cuddly and Blue!" line you would expect. Instead, IE tries to return the value of the form itself.


Known Workarounds: One. Use the fix for (bug 152)


Related Issues: (bug 152).