Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
// this is how I fixed IE6-8 crashing on
// dynamic insertion of at-rules inside
// stylesheets (for example @font-face)
// 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