Skip to content

Instantly share code, notes, and snippets.

@Geruhn
Created November 25, 2013 16:59
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Geruhn/7644599 to your computer and use it in GitHub Desktop.
Save Geruhn/7644599 to your computer and use it in GitHub Desktop.
JavaScript: addGlobalStyle(css)
function addGlobalStyle(css) {
var head, style;
head = document.getElementsByTagName('head')[0];
if (!head) { return; }
style = document.createElement('style');
style.type = 'text/css';
style.innerHTML = css;
head.appendChild(style);
}
@stewil87
Copy link

stewil87 commented Apr 3, 2015

Works perfectly, Thank you. I used it in one of my scripts here. I commented your snippet. I hope this is ok for you?

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