Created
April 22, 2012 08:42
-
-
Save brunjo/2462761 to your computer and use it in GitHub Desktop.
JavaScript - detect CSS transform 3d support and supported browser prefix
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
//window.onload=function(){ | |
var supportedPrefix, | |
supports3d = false, | |
prefixes = [ "Webkit", "Moz", "ms", "O" ], | |
div = document.createElement("div"); | |
if ( div.style.perspective !== undefined ) { | |
/*Browser supports CSS transform 3d without prefix*/ | |
supportedPrefix = ""; | |
supports3d = true; | |
}else { | |
for ( var i = 0; i < prefixes.length; ++i ) { | |
if((prefixes[i] + "Perspective") in div.style) { | |
supports3d = true; | |
supportedPrefix = prefixes[i]; | |
break; | |
} | |
} | |
} | |
console.log("supports3d: " + supports3d + "; browser prefix: " + supportedPrefix); | |
//} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment