How can I get the actual te开发者_JS百科xt of a stylesheet using JS?
The cssRules property only returns those rules that it recognizes.
eg. I would like to change -webkit-border-radius to -moz-border-radius. Or do some JS wizardry to any element who's style contains myTrigger:true; (Do NOT lecture me on principal.)
Cycling through document.stylesheet's cssRules returns the parsed text minus any unrecognized rules, whether I use cssText, the array of rules, or the default rules.
Is there any way to parse an included stylesheet and view/modify each of the rules as it was actually written?
The only way to do this is to load the stylesheet directly with a JavaScript xmlhttprequest then parse the contents yourself. Then, after doing that, use the JavaScript to insert your modified styles into the head of the HTML document.
Messy, but it'll work.
精彩评论