【发布时间】:2012-10-10 19:13:24
【问题描述】:
有没有办法获取应用于页面的所有 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>";
【问题讨论】:
标签: asp.net stylesheet