Problems with setAttribute in IE
Nov. 13, 2006 No Comments Posted under: Blog, CSS, Hijax, JavaScript
Whilst being Pr0 and trying to work around IE’s inability to understand the CSS :after class I used JavaScript to add a clearing element after the classes through the DOM, but only for IE. (I know browser sniffing is wrong but if it adds in a clearing element in Opera too there won’t be any ill effect).
Anyway I found that Internet Explorer can’t add style content through setAttribute and also can’t seem to set the class name and then apply the class from the CSS.
After a bit of digging on the web I found that you can use setAttribute(“className”,”clearAll”); to do the same in IE. This works fine but be sure to remember that if Opera or Camino are pretending to be IE they wont add the class name through className so it’s worth adding a class in too, just as a back up. (Why can’t browsers pretending to be IE not have another navigator element saying their true identity)
Thanks to quirksmode
for the info on this!
This entry was posted on Monday, November 13th, 2006 at 12:43 pm and is filed under Blog, CSS, Hijax, JavaScript. You can leave a comment and follow any responses to this entry through the RSS 2.0 feed.