Skip to content Skip to sidebar Skip to footer

Get Text Of A Modified Stylesheet (Firefox)

I am programmatically (JS) rewriting stylesheets for a web page. (I have a copy of the page and all assets stored locally on a server.) Once I'm done rewriting the stylesheets, I

Solution 1:

You'll have to use something like the following (fiddle):

for (var si = 0; si < document.styleSheets.length; ++si) {
    var ss = document.styleSheets[si];

    var href = ss.href || "<inline>";
    var rules = [];
    for (var ri = 0; ri < ss.cssRules.length; ++ri) {
        rules.push(ss.cssRules[ri].cssText);
    }
}

Read the MDN docs, in particular "Using dynamic styling information".


Post a Comment for "Get Text Of A Modified Stylesheet (Firefox)"