css float formating with javascript versus IE

Posted by on iulie 31, 2007
Fără categorie

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:

a

a

a



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';

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.

a

a

a



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';

1 Comment to css float formating with javascript versus IE

Lasă un răspuns

Adresa ta de email nu va fi publicată. Câmpurile obligatorii sunt marcate cu *

Acest site folosește Akismet pentru a reduce spamul. Află cum sunt procesate datele comentariilor tale.