-
-
Save vladkrasovsky/d3b9d6282917b6820b768ffbc1835fde to your computer and use it in GitHub Desktop.
Quick jquery plugin to check navigator.userAgent string
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
(function($){ | |
function getInternetExplorerVersion() { | |
var rv = -1; | |
if (navigator.appName == 'Microsoft Internet Explorer') { | |
var ua = navigator.userAgent; | |
var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})"); | |
if (re.exec(ua) != null) | |
rv = parseFloat( RegExp.$1 ); | |
} | |
return rv; | |
} | |
$.extend({ | |
eyebrowser: function() { | |
var agentString = navigator.userAgent.toString(); | |
if(/Chrome/.test(agentString)) { | |
return "Chrome"; | |
} else if(/Firefox/.test(agentString)){ | |
return "Firefox"; | |
} else if(/MSIE/.test(agentString)) { | |
var iev = getInternetExplorerVersion(); | |
return "IE "+iev; | |
} else if(/Opera/.test(agentString)) { | |
return "Opera"; | |
} else { | |
return "Other browser"; | |
} | |
} | |
}); | |
})(jQuery) | |
// alert($.eyebrowser()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment