Created
July 22, 2012 03:30
-
-
Save ahomu/3158258 to your computer and use it in GitHub Desktop.
ベンダープレフィックス決めるくん.js
This file contains hidden or 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