Created
March 20, 2011 03:24
-
-
Save eligrey/878039 to your computer and use it in GitHub Desktop.
document.createStyleSheet(rules)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.