This week I was working on our content management system. I needed to insert named anchors before specific DOM nodes. Doing so I found out that you are unable to set the
name attribute of an anchor in IE. Take a look at the following code:
var div = document.createElement('div'); var a = document.createElement('a'); a.setAttribute('name', 'whatever'); div.appendChild(a); alert(div.innerHTML);
To meet the deadline I used the
onload attribute instead and replaced
<a onload by
<a name afterwards. Not very pretty. Anyone any better ideas?