Skip to content

Instantly share code, notes, and snippets.

@johnkpaul
Created February 6, 2012 20:58
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 johnkpaul/1754808 to your computer and use it in GitHub Desktop.
Save johnkpaul/1754808 to your computer and use it in GitHub Desktop.
Approximate cssText on a CSSStyleDeclaration object in Firefox
function getComputedStyleCssText(element){
var cssObject = window.getComputedStyle(element),
prop,
cssText,
cssAccumulator = [];
if(cssObject.cssText != ""){
return cssObject.cssText;
}
for(prop in cssObject){
if(typeof cssObject[prop] == "string"){
cssAccumulator.push(prop + " : " + cssObject[prop]);
}
}
return cssAccumulator.join("; ");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment