views:

281

answers:

2

Has anyone had luck getting the contents of a stylesheet loaded with a tag?

A: 

jQuery

var link = $('#linkID');
$.get(link.attr('href'), '', function(data) {
    alert(data);
});

The fact that I am way too lazy to write the native JS way proves that you should use jQuery.

jQuery

ChaosPandion
Problem with this is that its doing a 2nd GET request to load the data. Already know how to do that. Thanks though.
Geuis
+1  A: 

If you want to get the content of already-loaded stylesheets without an additional HTTP request, the best place to start is the document.styleSheets object. Here's documentation (from MDC, but IE's implementation is largely similar): https://developer.mozilla.org/En/DOM/document.styleSheets

eyelidlessness