Skip to content

Instantly share code, notes, and snippets.

@fearphage
Forked from dperini/ie-inject-style-rules.js
Created June 23, 2010 17:32
Show Gist options
  • Select an option

  • Save fearphage/450255 to your computer and use it in GitHub Desktop.

Select an option

Save fearphage/450255 to your computer and use it in GitHub Desktop.
// this is how I fixed IE crashing on
// dynamic injections of AtRules inside
// stylesheets (for example @font-face)
function setStyle(rules) {
var d = document,
s = d.createElement('style'),
h = d.getElementsByTagName('head')[0] || d.documentElement;
s.type = 'text/css';
d.createElement('div').appendChild(s).styleSheet.cssText = rules;
h.insertBefore(s, h.firstChild);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment