Skip to content

Instantly share code, notes, and snippets.

@garystorey
Created July 20, 2015 15:05
Show Gist options
  • Select an option

  • Save garystorey/aa59aaa3443dcb010189 to your computer and use it in GitHub Desktop.

Select an option

Save garystorey/aa59aaa3443dcb010189 to your computer and use it in GitHub Desktop.
Detect OS and Browser
var 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") {
} else if (OS =="Mac" && bName=="Microsoft Internet Explorer") {
} else if (OS =="Win" || OS == "Linux" && bName == "Netscape") {
} else if (OS =="Solaris" && bName=="Netscape") {
} else if (OS =="Win" || OS == "Linux" && bName=="Microsoft Internet Explorer") {
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment