[thelist] Reading out the "for" atttribute via Javascript

Andrew Clover and-evolt at doxdesk.com
Thu Feb 24 22:10:20 CST 2005

Chris Heilmann wrote:

> IE needs yourobject.getAttribute('htmlFor').

This is a symptom of a wider brokenness in IE/Win. IE's lame 
implementation of node.getAttribute('x') just works as getting the 
JavaScript property (node['x']). This means:

   a. you can do silly things like node.getAttribute('nodeName')
   b. HTML attributes named differently from JS properties don't work.

Other problematically-named HTML attributes include 'className' and 
'value' (which *should* work differently from the JS property 'value' on 
form fields).

So, avoid using DOM Core getAttribute when there's a DOM HTML equivalent 
- it's likely to work better on IE to simply say label.htmlFor.

Andrew Clover
mailto:and at doxdesk.com

More information about the thelist mailing list