For reasons we dont need to get in to, I need to put the content of a CSS-file into the style tags of a html-page. I want to do it automatically, so I need to read the CSS file and put it's content in my style tag in my header.
Any idea how to do this?
The best would be if you used PHP, django, ASP.net or something from this family.
For PHP I would do like this:
<style id="Something">
<?php readfile("http://example.com/some/style.css"); ?>
</style>
But if you want to use jQuery, try this:
<style id="Something"></style>
<script type="text/javascript">
var request = $.ajax({
url: "stylesheet.css",
});
request.done(function( msg ) {
$( "style#Something" ).html( msg );
});
request.fail(function( jqXHR, textStatus ) {
alert( "Request failed: " + textStatus );
});
</script>