-
-
Save TerasawaShuhei/5622737 to your computer and use it in GitHub Desktop.
ベンダープレフィックス決めるくん.js
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
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