Skip to content

Instantly share code, notes, and snippets.

@os0x
Created January 26, 2009 03:18
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save os0x/52682 to your computer and use it in GitHub Desktop.
Save os0x/52682 to your computer and use it in GitHub Desktop.
function addCSS (css){
if (document.createStyleSheet) { // for IE
var sheet = document.createStyleSheet();
sheet.cssText = css;
return sheet;
} else {
var sheet = document.createElement('style');
sheet.type = 'text/css';
var _root = document.getElementsByTagName('head')[0] || document.documentElement;
sheet.textContent = css;
return _root.appendChild(sheet).sheet;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment