windy
02-09-2007, 09:48 PM
I am traversing a list of element nodes where some have the id attribute and others don't. When I use getAttribute('id') in Opera 9 or FF2 and the attribute doesn't exist, these browser return null and typeof=object. In IE(7) I get an empty value with typeof=string with length=0.
So, I have to use :
attr = elm.getAttribute('id');
if(typeof(attr)=='string'){
if(attr.length>0){alert('attribute doesnt exist');}
}
Is this the appropriate cross browser work around ?
(see also http://tobielangel.com/2007/1/11/attribute-nightmare-in-ie)
So, I have to use :
attr = elm.getAttribute('id');
if(typeof(attr)=='string'){
if(attr.length>0){alert('attribute doesnt exist');}
}
Is this the appropriate cross browser work around ?
(see also http://tobielangel.com/2007/1/11/attribute-nightmare-in-ie)