Created
February 18, 2011 13:43
-
-
Save andrewn/833666 to your computer and use it in GitHub Desktop.
Detect if CSS Transforms are supported
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
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