I am trying to read a custom (non-standard) CSS property, set in a stylesheet (not the inline style attribute) and get its value. Take this CSS for example:
#someElement {
foo: 'bar';
}
I have managed to get its value with the currentStyle property in IE7:
var element = document.getElementById('someElement');
var val = element.currentStyle.foo;
But currentStyle is MS-specific. So I tried getComputedStyle() in Firefox 3 and Safari 3:
var val = getComputedStyle(element,null).foo;
...and it returns undefined. Does anyone know a cross-browser way of retreiving a custom CSS property value?
(As you might have noticed, this isn't valid CSS. But it should work as long as the value follows the correct syntax. A better property name would be "-myNameSpace-foo" or something.)