Een stylesheet is embedded opgenomen in de HTML. Gebruikmakende van Prototype worden vervolgens diverse stijlen aangepast middels:
Vervolgens doe ik een poging om de complete stylesheet uit te lezen:
Dit levert klaarblijkelijk de initiële stylesheet op, waar de veranderingen niet in zijn doorgevoerd. Deze site beschrijft het probleem:
code:
1
| $('div1').style.background = color; |
Vervolgens doe ik een poging om de complete stylesheet uit te lezen:
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
| if (document.styleSheets) for (sheetKey in document.styleSheets) if (document.styleSheets[sheetKey]['title'] == 'stylesheet1') { var rules = ''; for (ruleKey in document.styleSheets[sheetKey].cssRules) { if (document.styleSheets[sheetKey].cssRules[ruleKey].cssText != undefined) rules += document.styleSheets[sheetKey].cssRules[ruleKey].cssText+'\r\n'; } alert(rules); break; } |
Dit levert klaarblijkelijk de initiële stylesheet op, waar de veranderingen niet in zijn doorgevoerd. Deze site beschrijft het probleem:
getComputedStyle moet worden aangeroepen op een specifiek element, ik heb zodoende wat problemen om de complete stylesheet uit te lezen. Heeft iemand tips?If you use the former method to read the style properties for H1, but have declared them inline as in the latter example, you get the wrong values—those defined in the embedded stylesheet, not those defined in the inline style attribute. ...
There is a standard way to read the current style properties for any element, the getComputedStyle() method, but it is not yet supported on the Macintosh platform.