Skip to content

Instantly share code, notes, and snippets.

@maxfell
Created January 5, 2012 20:59
Show Gist options
  • Save maxfell/1567256 to your computer and use it in GitHub Desktop.
Save maxfell/1567256 to your computer and use it in GitHub Desktop.
Art Directed posts in tumblr
<!-- Make sure to load the injectCSS() function when the body is loading -->
<body onload="injectCSS();">
FUN
</body>
<script type="text/javascript">
function injectCSS() {
var css = '/*THECSS*/';
if ('\v' == 'v') /* ie only */
{
document.createStyleSheet().cssText = css;
} else {
var style = document.createElement('STYLE');
style.type = 'text/css';
style.innerHTML = css;
document.getElementsByTagName('HEAD')[0].appendChild(style);
}
}
</script>
@maxfell
Copy link
Author

maxfell commented Jan 5, 2012

I was looking for a way to make Art Directed posts in tumblr. Then I found out that it's possible to embed HTML-Tags in Tumblr post. This is the last missing piece to inject CSS-Stylesheets into the page.
Make sure to call the injectCSS(); function when the page is ready.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment