Pixelbox

Welcome to Pixelbox. Friday the 5 of September 2008

Skip to content >>

Problems with setAttribute in IE

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!
Meta tags: Blog, CSS, Hijax, JavaScript

Truncating HTML elements through the DOM

After the launch of Monkey I have had time to (been forced to) do some other projects. Whilst being a nice change it’s also rather annoying not getting to polish something once you have got the first release out. However needs must and hopefully I will be back on it soon. Being back on the front [...]

An Ajax.Periodical Updater that you can turn off!

At work recently I came across an instance where I wanted to turn a script.aculo.us Ajax.Periodical Updater on and off. After looking on the wiki it appeared that there was no way to turn the thing off once you had started it other than reloading the page. You could for example want to turn it off [...]

« Previous Page