Strainu onLine
Blogul unui automatist
31st
JUL
css float formating with javascript versus IE
Posted by dragos | Filed under HTML
If you ever, by any chance try to format some HTML elements with javascript, and that formating would refer to float propertries, please be aware. Let me give you the most simple example I’ve met:
document.getElementById('a1').style.width='100px';
document.getElementById('a2').style.width='100px';
document.getElementById('a3').style.width='100px';
document.getElementById('a1').style.backgroundColor = '#FF0000';
document.getElementById('a2').style.backgroundColor = '#FF0000';
document.getElementById('a3').style.backgroundColor = '#FF0000';
document.getElementById('a1').style.cssFloat= 'left';
document.getElementById('a2').style.cssFloat= 'left';
document.getElementById('a3').style.cssFloat= 'left';
document.getElementById('a2').style.width='100px';
document.getElementById('a3').style.width='100px';
document.getElementById('a1').style.backgroundColor = '#FF0000';
document.getElementById('a2').style.backgroundColor = '#FF0000';
document.getElementById('a3').style.backgroundColor = '#FF0000';
document.getElementById('a1').style.cssFloat= 'left';
document.getElementById('a2').style.cssFloat= 'left';
document.getElementById('a3').style.cssFloat= 'left';
All the browsers will interpret it well, EXCEPT IE. On IE, the previous formating of the divs remains. The solution took me about 2 hours, and it looks like this. Do not ask me if changing the floating now would work, ’cause I don’t know. I’m just to afraid even to think at such thing.
document.getElementById('a1').style.width='100px';
document.getElementById('a2').style.width='100px';
document.getElementById('a3').style.width='100px';
document.getElementById('a1').style.backgroundColor = '#FF0000';
document.getElementById('a2').style.backgroundColor = '#FF0000';
document.getElementById('a3').style.backgroundColor = '#FF0000';
document.getElementById('a2').style.width='100px';
document.getElementById('a3').style.width='100px';
document.getElementById('a1').style.backgroundColor = '#FF0000';
document.getElementById('a2').style.backgroundColor = '#FF0000';
document.getElementById('a3').style.backgroundColor = '#FF0000';
Reader's Comments
Leave a Reply
Post Meta
-
July 31, 2007 -
HTML -
One Comments
-
Comments Feed -
Facebook
-
Tweet This





for IE
document.getElementById(‘a1′).style.styleFloat= ‘left’;
explained eg. on
http://www.howtocreate.co.uk/tutorials/javascript/domcss