I found the need to extract the element set style in the browser (made by the user). I should be able to work with extracted styles on my server (server side javascript and jQuery). Now the problem is that many browsers use their own naming conventions or like to split abbreviations into separate elements, while others do not.
One solution for me would be to get an element style literal string (styles from style sheets should not be taken into account). In Firefox / Chrome, this will work:
node.getAttribute('style')
Unfortunately, this is not possible in Internet Explorer 5/6/7. I decided that this would be the solution:
function getStyleStr(node) {
return typeof(node.getAttribute('style')) !== 'string' ? node.style.cssText : node.getAttribute('style');
}
http://jsfiddle.net/8p5BN/6/
Unfortunately, node.style.cssText does not return a literal string, as described here: http://javascript.gakaa.com/style-csstext.aspx
Is there a better way to define the style of an element set in a cross browser with the same name?
source
share