Skip to content

Instantly share code, notes, and snippets.

@cheng470
Created October 8, 2014 09:38
Show Gist options
  • Save cheng470/a38aa78c391d08b96a8c to your computer and use it in GitHub Desktop.
Save cheng470/a38aa78c391d08b96a8c to your computer and use it in GitHub Desktop.
var browser = (function(){
var s = navigator.userAgent.toLowerCase();
var m = /(webkit)[ \/]([\w.]+)/.exec(s) ||
/(opera)(?:.*version)?[ \/]([\w.]+)/.exec(s) ||
/(msie) ([\w.]+)/.exec(s) ||
(!(/compatible/.test(s)) && /(mozilla)(?:.*? rv:([\w.]+))?/.exec(s)) ||
[];
return {
userAgent: navigator.userAgent,
name: m[1] || "",
version: m[2] || "0"
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment