Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I am running a javascript environment at x.y.com, but I need to read to content of a css file at a.b.com. Is there any way to make an ajax call to load the content of this file as a text string? Does doing this violate the "spirit" of the Same-Origin policy on various browsers? Basically, I'm trying to compile a list of ALL the CSS Rules affecting a page, even those loaded from cross-origin external css files (whose rules are not shown in document.styleSheets[x].cssRules[]).

share|improve this question
 
It does violate the spirit and the letter of the Same Origin policy, yes... but are you sure those style sheets don't show up in document.styleSheets when loaded the normal way? That would be strange. –  Pekka 웃 Jan 8 at 19:15
 
They do not - cross-origin CSS Rules are not listed in 'document.styleSheets' –  AlexZ Jan 8 at 19:28
 
You can load the contents of the file via CORS or JSONP. Both require cooperation from the remote server. Or, you could proxy the file from your local server. –  Ray Nicholus Jan 8 at 19:50
 
Sadly, this is a content script that I am running on top of an existing page I don't control, so I have no control over the remote hosting of these files and proxying is out of the question. –  AlexZ Jan 8 at 20:25
 
Then there is no way for you to request and read these cross-domain files in the browser. –  Ray Nicholus Jan 8 at 20:26
add comment

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.