0

有没有办法获取应用于页面的所有 CSS 规则?目前,我正在使用 jQuery 来执行此操作,但是否有服务器端解决方案?

var style = "";

//grab all styles defined on the page
$("style").each(function () {
    style += $(this).html() + "\n";
});

$.ajaxSetup({ async: false });
//grab all styles referenced by stylesheet links on the page
$("[rel=stylesheet]").each(function () {
    $.get(this.href, '', function (data) {
        style += data + "\n";
    });
});
$.ajaxSetup({async: true});
style = "<style type='text/css'>" + style + "</style>";
4

1 回答 1

0

You can try with HtmlHead.StyleSheet property

Link : http://msdn.microsoft.com/en-us/library/system.web.ui.htmlcontrols.htmlhead.stylesheet.aspx

于 2012-10-10T19:17:51.727 回答