⬅︎ Back to setAttribute('style', ...) workaround for IE
This is great! I've improved it just a bit: _setStyle: function (aElement /* object */, aDeclaration /* CSS Declaration */) { try { if (aElement) { aDeclaration = aDeclaration.replace(/\s+/g,''); // remove all white spaces if (document.all) { // IE Hack if (aDeclaration.charAt(aDeclaration.length-1)==';') aDeclaration = aDeclaration.slice(0, -1); var k, v; var splitted = aDeclaration.split(';'); for (var i=0, len=splitted.length; i<len; i++) { k = rzCC(splitted[i].split(':')[0]); v = splitted[i].split(':')[1]; eval("aElement.style."+k+"='"+v+"'"); } return (true); } else { // The clean way aElement.setAttribute ('style', aDeclaration); return (true); } } } catch (e) { return (false); } }Hope you like it. Good job mate ;)
Comment
This is great! I've improved it just a bit:
_setStyle: function (aElement /* object */, aDeclaration /* CSS Declaration */) {
try {
if (aElement) {
aDeclaration = aDeclaration.replace(/\s+/g,''); // remove all white spaces
if (document.all) { // IE Hack
if (aDeclaration.charAt(aDeclaration.length-1)==';')
aDeclaration = aDeclaration.slice(0, -1);
var k, v;
var splitted = aDeclaration.split(';');
for (var i=0, len=splitted.length; i<len; i++) {
k = rzCC(splitted[i].split(':')[0]);
v = splitted[i].split(':')[1];
eval("aElement.style."+k+"='"+v+"'");
}
return (true);
} else { // The clean way
aElement.setAttribute ('style', aDeclaration);
return (true);
}
}
} catch (e) {
return (false);
}
}
Hope you like it. Good job mate ;)