Skip to content

Instantly share code, notes, and snippets.

@hara-y-u
Created October 31, 2011 11:47
Show Gist options
  • Save hara-y-u/1327332 to your computer and use it in GitHub Desktop.
Save hara-y-u/1327332 to your computer and use it in GitHub Desktop.
Easy userAgent Access
var UA = (function(ua) {
var browsers = {
// Capture: Major#, #2, #3, #4, alphaBeta, alphaBeta#
ie: /InternetExplorer/
, fx: /firefox\/(\d+)(?:\.(\d+))?(?:\.(\d+))?(?:\.(\d+))?(?:(a|b)(\d*))?/i
, cr: /Chrome/
, sf: /Safari/
, op: /Opera/
}, key, ret, obj = {};
for(key in browsers) {
if(ret = ua.match(browsers[key])) {
obj[key] = ret;
return obj;
}
}
}(navigator.userAgent));
@hara-y-u
Copy link
Author

とりあえず firefox だけ。

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