Skip to content

Instantly share code, notes, and snippets.

@paulirish
Created August 13, 2010 23:13
Show Gist options
  • Save paulirish/523692 to your computer and use it in GitHub Desktop.
Save paulirish/523692 to your computer and use it in GitHub Desktop.
// find out what prefix this browser supports.
// usage: gimmePrefix('transform') // 'WebkitTransform'
// returns false if unsupported.
function gimmePrefix(prop){
var prefixes = ['Moz','Khtml','Webkit','O','ms'],
elem = document.createElement('div'),
upper = prop.charAt(0).toUpperCase() + prop.slice(1);
if (prop in elem.style)
return prop;
for (var len = prefixes.length; len--; ){
if ((prefixes[len] + upper) in elem.style)
return (prefixes[len] + upper);
}
return false;
}
// btw this is available as Modernizr.prefixed(prop) now.
@paulirish
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment