Skip to content

Instantly share code, notes, and snippets.

@Zillionx
Last active July 3, 2017 09:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Zillionx/e9d641cb68dce87154fe to your computer and use it in GitHub Desktop.
Save Zillionx/e9d641cb68dce87154fe to your computer and use it in GitHub Desktop.
Javascript OS client detection with url redirect
/* Zilli 201507
To detect the operating system on the client machine,
match the value of navigator.appVersion,
then redirect to OS url with the location.replace value.
*/
if (navigator.appVersion.match(/Mac/i)) {
location.replace("index-Mac.html");
}
else if (navigator.appVersion.match(/Win/i)) {
location.replace("index-Win.html");
}
else if (navigator.appVersion.match(/UNIX/i)) {
location.replace("index-Unix.html");
}
else if (navigator.appVersion.match(/Linux/i)) {
location.replace("index-Linux.html");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment