setting css float with javascript in IE

Just a quick reminder to self:
IE 6 (7) don’t seem to render style.float when set with javascript,
so when you want a div to float left *dont* try using:

 div.styleFloat = 'left';
 div.style['float'] = 'left';
 div.style.float = 'left';


but create a class:

 .fll { float:left; }
 .flr { float:right; }
 .fln { float:none; }

and set the classname in javascript to invoke float:

 div.className="fll";

Another issue with IE and IE only is that setting your style directives with:

 div.setAttribute("style", "float:left;" );

doesn’t seem to work: setting background-image, font-size, floats or any other css style item will not render. damn.


No Responses to “setting css float with javascript in IE”

Responses are currently closed, but you can trackback from your own site.

Comments are closed.