Automatically Inline Css From A Css-file (jquery? Ajax? Php?)
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
Solution 1:
The best would be if you used PHP, django, ASP.net or something from this family. For PHP I would do like this:
<styleid="Something"><?php readfile("http://example.com/some/style.css"); ?></style>
But if you want to use jQuery, try this:
<styleid="Something"></style><scripttype="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>
Post a Comment for "Automatically Inline Css From A Css-file (jquery? Ajax? Php?)"