Used for reading a value from the loaded stylesheet. Only support the usage of one stylesheet file. Supports selectors beeing grouped and defined in multiple blocks.
1
2 function getCssValue(selector,attribute)
3 {
4 selector = selector.toLowerCase();
5 var stylesheet = document.styleSheets[0];
6 var n = stylesheet.cssRules.length;
7 for(var i=0; i<n; i++)
8 {
9 var selectors = stylesheet.cssRules[i].selectorText.toLowerCase().split(",");
10 var m = selectors.length;
11 for(j=0; j<m; j++)
12 {
13 if(selectors[j].trim() == selector)
14 {
15 var value = stylesheet.cssRules[i].style.getPropertyValue(attribute);
16 if(value!="")
17 {
18 return value;
19 }
20 }
21 }
22 }
23 debug("Could not find selector/attribute: "+selector+"/"+attribute);
24 return null;
25 },