I can get the content of a single css file this way
getStyleCSS = $.get("MyStyle.css");
$.when(getStyleCSS).done(function(response) {
var strCSS = response; // response here is the text content of the css file
}
But when I try to get several css file contents like this I get Deferred objects instead of the css contents.
// Get a handle on an aspx created element which contains css script elements
var elementDiv = document.getElementById('somediv');
// Get the stylesheets from this element
var links= elementDiv.getElementsByTagName('link');
arrLinks = [];
arrDeferreds = [];
// jQuery get each of the css links
for (var i = 0; i < arrLinks.length; i++) {
var link = arrLinks[i];
arrDeferreds.push($.get(link));
}
// Fetch the css documents
$.when(arrDeferreds).done(function (response) {
var result = response; // response here is an array of Deferred objects
}
Is there a way to get the text content of multiple css files using javascript/jQuery?
Context: I need to send a subset of a page's HTML to an external (cross site) service which will generate a PDF of the specified HTML. In order for the pdf to be generated properly I need to embed the text of all css content into the html. The page contents originate with aspx/ascx controls and some of those controls contain script elements pointing to various css files. I'm trying to fetch the css text content of for each of these elements.