Skip to content

Instantly share code, notes, and snippets.

@cramforce
Created August 20, 2010 16:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cramforce/540678 to your computer and use it in GitHub Desktop.
Save cramforce/540678 to your computer and use it in GitHub Desktop.
var fullreset = (function () {
$(function () {
var iframe = document.createElement("iframe");
$("body").append(iframe);
var doc = iframe.contentDocument;
var win = iframe.contentWindow;
doc.open();
var html = "<!DOCTYPE html>\n"+
"<html><body><p>Not Red</p></body></html>";
doc.write(html);
doc.close();
var p = doc.getElementsByTagName("p")[0];
var curCSS = win.getComputedStyle(p, null)
var text = "#reset p {\n";
for(var i = 0; i < curCSS.length; i++) {
var name = curCSS[i];
text += name+": "+curCSS.getPropertyValue(name)+";\n"
}
text += "}\n"
$("body").append("<pre>"+text+"</pre>");
$("body").append('<style type="text/css">'+text+'</style>')
});
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment