Skip to content

Instantly share code, notes, and snippets.

@dperini
Created June 23, 2010 16:27
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save dperini/450163 to your computer and use it in GitHub Desktop.
Save dperini/450163 to your computer and use it in GitHub Desktop.
// this is how I fixed IE6-8 crashing on
// dynamic insertion of at-rules inside
// stylesheets (for example @font-face)
// UPDATE:
// Fix by MS, move up the style insertion
// before the stylesheet rule manipulation
function setStyle(rules) {
var d = document,
r = d.documentElement,
s = d.createElement('style'),
h = d.getElementsByTagName('head')[0] || r;
s.type = 'text/css';
h.insertBefore(s, h.firstChild);
s.styleSheet.cssText = rules;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment