Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS Blocking CSS to get browser basic HTML Reply To: Blocking CSS to get browser basic HTML

#237798
Shikkediel
Participant

Yeah, you could use the identifiers and test them against a regular expression in the stylesheet. Then delete those rules that match. Or more likely, rewrite them if they are shared with other elements that they should still apply to. Probably quite slow and complicated for sure.

Not completely pointless under all circumstances… I’ve used cssRules myself to clone some HTML for a magnifier. Then find any unique identifiers and copy the style under a duplicate name so the cloned version won’t violate uniqueness.

http://ataredo.com/morphology/magnify/

function transFigure() {

    var sheet = document.styleSheets[0],
    styles = sheet.cssRules, rules = [];

    $.each(individual, function() {

    var tag = this.id, selector = '#' + tag,
    pattern = new RegExp(selector + '(:| |,)');

    $.each(styles, function() {
    var string = this.cssText;
    if (pattern.test(string)) {
    var rule = string.replace(selector, selector + '-magnified');
    rules.push(rule);
    }
    });
    $(this).attr('id', tag + '-magnified');
    });

    $.each(rules, function() {
    var index = styles.length;
    sheet.insertRule(this, index);
    });
}