Determine Operating System

Submitted by:Jhon Jhon

Date added:02 August, 2014

Category:JavaScript

JavaScript code to detects browser and OS

Tags: detects browser , detects os

Code Snippet:

<SCRIPT type="text/JavaScript">

//Determine Operating System
system=navigator.appVersion;
IF (navigator.appVersion.indexOf("Mac") != -1 ) OS = "Mac";
ELSE IF (navigator.appVersion.indexOf("PowerPC") != -1 ) OS = "Mac";
ELSE IF (navigator.appVersion.indexOf("Win") != -1 ) OS = "Win";
ELSE IF (navigator.appVersion.indexOf("SunOS") != -1 ) OS = "Solaris";
ELSE OS = "Linux";

//Determine Browser Version
bName = navigator.appName;
bVer = parseInt(navigator.appVersion);

IF (OS == "Mac" && bName=="Netscape"){
// your code here
}
ELSE IF (OS =="Mac" && bName=="Microsoft Internet Explorer"){
// your code here
}
ELSE IF (OS =="Win" | OS == "Linux" && bName=="Netscape"){
// your code here
}
ELSE IF (OS =="Solaris" && bName=="Netscape"){
// your code here
}
ELSE IF (OS =="Win" | OS == "Linux" && bName=="Microsoft Internet Explorer"){
// your code here
}

</SCRIPT>
 
 

Comments