According to SitePoint (and my own experiments), the IE implementation of \"setAttribute()\" is buggy and unreliable.
Also according to SitePoint, the name
name
Looking at W3C DOM Compatibility - Core you could try using setAttributeNode() instead of setAttribute(). It may work on IE 6 and above.