Skip to content

Instantly share code, notes, and snippets.

@natebenes
Created September 28, 2010 13:32
Show Gist options
  • Select an option

  • Save natebenes/600993 to your computer and use it in GitHub Desktop.

Select an option

Save natebenes/600993 to your computer and use it in GitHub Desktop.
function () {
DF.namespace("DF.browserInformation");
(DF.browserInformation = function () {
var a, b, d, g = [{
string: navigator.vendor,
searchStr: "Apple",
id: "Safari",
versionStr: "Version",
versMin: 1.3,
os: "mac"
},
{
string: navigator.userAgent,
searchStr: "Firefox",
id: "Firefox",
versMin: 1.1
},
{
string: navigator.userAgent,
searchStr: "MSIE",
id: "Explorer",
versionStr: "MSIE",
versMin: 6
},
{
string: navigator.userAgent,
searchStr: "Chrome",
id: "Chrome",
versMin: 99
},
{
string: navigator.userAgent,
searchStr: "Opera",
id: "Opera",
versMin: 99
}],
e = function () {
for (var i =
0; i < g.length; i++) {
var f = g[i].string;
if (f) if (f.indexOf(g[i].searchStr) !== -1) return g[i]
}
},
h = function () {
if (!a || a.os && a.os !== $.os.name) return -1;
b = navigator.userAgent;
var i = b.indexOf(a.versionStr || a.id),
f = null;
if (i !== -1) if (f = parseFloat(b.substring(i + (a.versionStr || a.id).length + 1))) return f;
b = navigator.appVersion;
i = b.indexOf(a.versionStr || a.id);
if (i !== -1) if (f = parseFloat(b.substring(i + (a.versionStr || a.id).length + 1))) return f;
return -1
},
l = function () {
return b
},
j = function () {
return a
},
c = function () {
return d
};
return {
init: function () {
a = e();
b = h(a);
d = a && b ? a.versMin <= b : false
},
getBrowser: function () {
return j()
},
getVersion: function () {
return l()
},
isSupported: function () {
return c()
},
isIE: function () {
return a.id === "Explorer"
}
}
}()).init()
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment