Last active
July 3, 2017 09:13
-
-
Save Zillionx/e9d641cb68dce87154fe to your computer and use it in GitHub Desktop.
Javascript OS client detection with url redirect
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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