Site Navigation

Showing posts with label 217. Show all posts
Showing posts with label 217. Show all posts

Friday, August 24, 2007

bug 217 - getAttribute doesn't always work in IE

Issue: #217
Affects: IE5, IE5.5, IE6, IE7

Certain attributes can not be retrieved properly in IE. The first example, is the "for" attribute, which is used by <label> tags to link to input fields.

Example:
<script type="text/javascript">
var myLabel = document.getElementById( 'test' );
alert( 'myLabel is for: ' + myLabel.getAttribute( 'for' ) );
</script>

There is a workaround for this (see below)


Known Workarounds: Some.

Example Workaround Code:
<script type="text/javascript">
var myLabel = document.getElementById( 'test' );
alert( 'myLabel is for: ' + myLabel.attributes['for'].nodeValue );
</script>



Related Issues: None.