L
-Lost
This relates to the setAttribute problems in Internet Explorer.
I have a function that accepts as one of its arguments an object that
stores style information. The style object specifically adheres to CSS
styles (not the camelCase JavaScript CSS).
This works wonderfully in all browsers (except IE), because I can simply
concatenate the style declarations then set them in one go via:
new_elem.setAttribute('style', style_obj);
Now, I realize the optimal thing (in IE) to do would be to set the
styles directly (or even create another function that dynamically
creates CSS classes and assigns them). However, the only thing I can
think of to achieve that would be to create a lookup function, so that
font-size becomes fontSize, et cetera.
Before I do that however, am I missing something? Could it be done in
an easier fashion? Can I allow the user to pass a style object like: {
color: '#f00', 'font-size': '2em' } and somehow set the styles directly
in IE without a lookup function?
(Sorry if this is isn't that clear. Been up all night with sick kids
and this is the best I can muster.)
Basically, am I on the right track with a lookup function or am I
missing something obvious?
Thanks guys (and gals?).
I have a function that accepts as one of its arguments an object that
stores style information. The style object specifically adheres to CSS
styles (not the camelCase JavaScript CSS).
This works wonderfully in all browsers (except IE), because I can simply
concatenate the style declarations then set them in one go via:
new_elem.setAttribute('style', style_obj);
Now, I realize the optimal thing (in IE) to do would be to set the
styles directly (or even create another function that dynamically
creates CSS classes and assigns them). However, the only thing I can
think of to achieve that would be to create a lookup function, so that
font-size becomes fontSize, et cetera.
Before I do that however, am I missing something? Could it be done in
an easier fashion? Can I allow the user to pass a style object like: {
color: '#f00', 'font-size': '2em' } and somehow set the styles directly
in IE without a lookup function?
(Sorry if this is isn't that clear. Been up all night with sick kids
and this is the best I can muster.)
Basically, am I on the right track with a lookup function or am I
missing something obvious?
Thanks guys (and gals?).