[Solved] Improving a Javascript browser detection function


This is what I neded up with. I Corrected bugs in Opera and Safari version detections and added SeaMonkey.

 <!DOCTYPE html>

 <script type="text/javascript">

 function GetBrowser(){
 var browser="";
 var version=0;

 if (/SeaMonkey[\/\s](\d+\.\d+)/.test(navigator.userAgent)){
  version=new Number(RegExp.$1);
  browser="SeaMonkey";} else {

  if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)){
   version=new Number(RegExp.$1);
   browser="Mozilla FireFox";} else {

   if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){
    version=new Number(RegExp.$1);
    browser="Internet Explorer";} else {

    if (/Opera/.test(navigator.userAgent)){
     if (/Version[\/\s](\d+\.\d+)/.test(navigator.userAgent)){version=new Number(RegExp.$1);}
     browser="Opera";} else {

     if (/Maxthon[\/\s](\d+\.\d+)/.test(navigator.userAgent)){
      version=new Number(RegExp.$1);
      browser="Maxthon";} else {

      if (/Chrome[\/\s](\d+\.\d+)/.test(navigator.userAgent)){
       version=new Number(RegExp.$1);
       browser="Google Chrome";} else {

       if (/Safari/.test(navigator.userAgent)){
        if (/Version[\/\s](\d+\.\d+)/.test(navigator.userAgent)){version=new Number(RegExp.$1);}
        browser="Safari";} else {browser="Unknown";}

 }}}}}}
 return browser+' '+version;}


 document.write(GetBrowser());

 </script>

4

solved Improving a Javascript browser detection function