Skip to content

Instantly share code, notes, and snippets.

function browserVersionOf(unprefixedName, parentObject) {
// parentObject is optional and usually omitted, set it to window if it's not specified.
parentObject = parentObject || window;
var baseName = unprefixedName.charAt(0).toUpperCase() + unprefixedName.substring(1);
var i = 0, variants = [unprefixedName, 'webkit', 'moz', 'ms', 'o'];
var fullName = variants[0];
do {
if (typeof parentObject[fullName] == 'function') {
return parentObject[fullName];
}