Skip to content

Instantly share code, notes, and snippets.

@jkfzero
Last active December 31, 2015 02:39
Show Gist options
  • Select an option

  • Save jkfzero/7922445 to your computer and use it in GitHub Desktop.

Select an option

Save jkfzero/7922445 to your computer and use it in GitHub Desktop.
Get browsers name and version. Modified from jquery-migrate.
var ua = navigator.userAgent.toLowerCase();
var match = /(chrome)[ \/]([\w.]+)/.exec(ua) ||
/(webkit)[ \/]([\w.]+)/.exec(ua) ||
/(opera)(?:.*version|)[ \/]([\w.]+)/.exec(ua) ||
/(msie) ([\w.]+)/.exec(ua) ||
ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec(ua) || [];
var browser = match[1] || "";
var version = match[2] || "0";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment