Posts tagged ie
<textarea id="description" name="description">Here is some text</textarea>
var myElement = document.getElementById('description');
alert(myElement.value.length); //alert: 17
Every time I tried to execute that code in IE it would complain that
'value.length' is null or not an object.
After a whole crap load of debugging I finally tracked it down to the fact that IE was actually referencing the <meta name=”description”> tag in the head section of the page. Yeah, see even though the function is getElementById, IE still thought I meant the element with the name attribute equal to “description”. Or as my brother put it in a comment to the original post (before the comments were wiped in the great Data Loss of ’06), maybe IE thought I was calling the getJustAboutAnythingIFeelLike() function…
Damn you IE for making me have to change my ID attributes to suite your leisurely implementation of the DOM!
* This post was originally published on April 5, 2007 at http://www.csb7.com/blogs/whyblogwhy/2007/04/05/ie_getelementbyid_bug_strikes_again