Looking to enhance my Javascript browser detection function with input from others.
Concerns:
The assumption that "Chrome 18" is equivalent to "Maxthon 3" may not be accurate! How can we distinguish between Chrome 18 and Maxthon 3?
Similarly, how can we differentiate between Firefox and Sea Monkey?
Can we identify the Lunar browser using navigator.userAgent?
Are there any other popular browsers I should consider?
Please provide pure Javascript solutions/suggestions only!
<!DOCTYPE html>
<script type="text/javascript">
function GetBrowser(){
var browser="";
var version=0;
if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)){
version=new Number(RegExp.$1);
browser="FireFox";} else {
if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){
version=new Number(RegExp.$1);
browser="Internet Explorer";} else {
if (/Opera[\/\s](\d+\.\d+)/.test(navigator.userAgent)){
version=new Number(RegExp.$1);
browser="Opera";} else {
if (/Chrome[\/\s](\d+\.\d+)/.test(navigator.userAgent)){
version=new Number(RegExp.$1);
if (version==18) {version=3; browser="Maxthon";} else {browser="Google Chrome"}} else {version=0; browser="Undetermined";}
}}}
return browser+' '+version;}
document.write(GetBrowser());
</script>