Skip to content

Instantly share code, notes, and snippets.

@eligrey
Created March 20, 2011 03:24
Show Gist options
  • Select an option

  • Save eligrey/878039 to your computer and use it in GitHub Desktop.

Select an option

Save eligrey/878039 to your computer and use it in GitHub Desktop.
document.createStyleSheet(rules)
Document.prototype.createStyleSheet = function (rules) {
var stylesheet = this.documentElement.appendChild(
this.createElementNS("http://www.w3.org/1999/xhtml", "style")
).sheet;
stylesheet.insertRule("@media all{" + rules + "}", 0);
return stylesheet;
};
@eligrey

eligrey commented May 16, 2011

Copy link
Copy Markdown
Author

I just noticed that IE has it's own proprietary document.createStyleSheet. Please note that this gist does not attempt to implement the IE method.

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