How do I use JavaScript to detect what operating system someone is using?

Omar Khan

Try this JavaScript code :-)


<SCRIPT LANGUAGE="JavaScript">
>!--
  function checkOS() {
   if(navigator.userAgent.indexOf('Linux') != -1)
     { var OpSys = "Linux"; }
   else if((navigator.userAgent.indexOf('Win') != -1) &&
   (navigator.userAgent.indexOf('95') != -1))
     { var OpSys = "Windows95"; }
   else if((navigator.userAgent.indexOf('Win') != -1) &&
   (navigator.userAgent.indexOf('NT') != -1)) 
     { var OpSys = "Windows NT"; }
   else if(navigator.userAgent.indexOf('Win') != -1) 
    { var OpSys = "Windows 3.1"; }
   else if(navigator.userAgent.indexOf('Mac') != -1)
     { var OpSys = "Macintosh"; }
   else { var OpSys = "operating system not recognised"; }
   return OpSys;
 }
 
 var OpSys = checkOS();
 alert("Your operating system is: " + OpSys);
  //-->
</SCRIPT>
0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact