Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save TerasawaShuhei/5622737 to your computer and use it in GitHub Desktop.
Save TerasawaShuhei/5622737 to your computer and use it in GitHub Desktop.
ベンダープレフィックス決めるくん.js
function detectVendorFunction(object, methodName) {
var upperName = methodName.charAt(0).toUpperCase()+methodName.substr(1),
detectedMethod;
detectedMethod = object[methodName] ||
object['webkit'+upperName] ||
object['moz'+upperName] ||
object['ms'+upperName] ||
object['o'+upperName];
if (detectedMethod) {
return detectedMethod;
} else {
throw new Error(methodName+' not found in specified object');
}
}
var getUserMedia = detectVendorFunction(navigator, 'getUserMedia');
var requestAnimationFrame = detectVendorFunction(window, 'requestAnimationFrame');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment