Skip to content

Instantly share code, notes, and snippets.

@brunjo
Created April 22, 2012 08:42
Show Gist options
  • Save brunjo/2462761 to your computer and use it in GitHub Desktop.
Save brunjo/2462761 to your computer and use it in GitHub Desktop.
JavaScript - detect CSS transform 3d support and supported browser prefix
//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