Last active
August 29, 2015 14:28
-
-
Save snadrus/726c4773a32ffaed4447 to your computer and use it in GitHub Desktop.
Use detect.js? It's a bit big for just trying to figure out what family your browser is. There's only 4 out there (2 variations of each) and they all have custom prefixed navigator objects. Lets just look for those! Detect.js-like output in 373chars (minified).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.detect={ | |
parse: function() { | |
var o = 'orientation' in window, prop, br, pre=['ms', 'moz','webkit']; | |
return { | |
isMobile: o, | |
browser: { | |
family: (o? "Mobile ":"Desktop ") + (function() { | |
for (prop in navigator) { | |
for (br in pre) { | |
if (!prop.indexOf(br)) { // IE 9 - Edge has "ms", else moz or webkit | |
return br==='webkit'?( | |
~navigator.vendor.indexOf("Google")?"Chrome": | |
~navigator.vendor.indexOf("Apple")?"Safari": | |
"Webkit") : | |
br=="ms" ? "Internet Explorer" : "Firefox"; | |
} | |
} | |
} | |
return "Unknown" | |
})() | |
} | |
}; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment