Javascript css float attribute

FYI for those of you trying to perform css float style updates programmatically, you have a little hurdle in order to apply this style correctly. Like the other style that have javascript counterparts through the use of element.style, the float property is a pretty much the same except that the actually style property name is not merely float – it is cssFloat in the case of mozilla and chrome, and in the case of IE: floatStyle.

This is not an overly complicated issue, however, if you are developing a framework for something or trying to be somewhat cross browser compatible.

var el=document.getElementById("example");
if(el!=null&&typeof(el.style.floatStyle)!="undefined"){
el.style.floatStyle="left";
}else{
el.style.cssFlow="left";
}
ttessier

About ttessier

Professional Developer and Operator of SwhistleSoft
This entry was posted in Javascript Development. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *