Skip to content

Instantly share code, notes, and snippets.

@andrewn
Created February 18, 2011 13:43
Show Gist options
  • Save andrewn/833666 to your computer and use it in GitHub Desktop.
Save andrewn/833666 to your computer and use it in GitHub Desktop.
Detect if CSS Transforms are supported
var el;
var prefixes = ["Webkit", "Moz", "O"];
// Test whether browser supports the given CSS property
// Name of CSS property to test must be in CamelCase i.e. borderRadius
function testProperty(prop) {
// create element to peform property detection against
el = el \|\| document.createElement("div");
// test standard property name first
if(el.style[prop] \!== undefined) return true;
prop = prop.charAt(0).toUpperCase() + prop.slice(1);
for(var i in prefixes)
{ if(el.style[ prefixes[i] + prop ] !== undefined) return true; }
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment