Created
August 21, 2014 17:52
-
-
Save wesdeboer/00fc4fd7da83375db303 to your computer and use it in GitHub Desktop.
Yes, I actually just saw this code snippet on a live site today.
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
function platformSniffer(macURL,os2URL,linuxURL,winURL) { | |
location.href = winURL; | |
var agt=navigator.userAgent.toLowerCase(); | |
var is_major = parseInt(navigator.appVersion); | |
var is_minor = parseFloat(navigator.appVersion); | |
var is_nav = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1) | |
&& (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1) | |
&& (agt.indexOf('webtv')==-1)); | |
var is_mac = (agt.indexOf("mac")!=-1); | |
var is_os2 = ((agt.indexOf("os/2")!=-1) || | |
(navigator.appVersion.indexOf("OS/2")!=-1) || | |
(agt.indexOf("ibm-webexplorer")!=-1)); | |
var is_linux = (agt.indexOf("inux")!=-1); | |
var is_win = ( (agt.indexOf("win")!=-1) || (agt.indexOf("16bit")!=-1) ); | |
var is_win95 = ((agt.indexOf("win95")!=-1) || (agt.indexOf("windows 95")!=-1)); | |
var is_win16 = ((agt.indexOf("win16")!=-1) || | |
(agt.indexOf("16bit")!=-1) || (agt.indexOf("windows 3.1")!=-1) || | |
(agt.indexOf("windows 16-bit")!=-1) ); | |
var is_win31 = ((agt.indexOf("windows 3.1")!=-1) || (agt.indexOf("win16")!=-1) || | |
(agt.indexOf("windows 16-bit")!=-1)); | |
var is_win98 = ((agt.indexOf("win98")!=-1) || (agt.indexOf("windows 98")!=-1)); | |
var is_winnt = ((agt.indexOf("winnt")!=-1) || (agt.indexOf("windows nt")!=-1)); | |
var is_win32 = (is_win95 || is_winnt || is_win98 || | |
((is_major >= 4) && (navigator.platform == "Win32")) || | |
(agt.indexOf("win32")!=-1) || (agt.indexOf("32bit")!=-1)); | |
if (is_mac) { // Macintosh | |
location.href = macURL; | |
} else if (is_os2) { // OS2 | |
//location.href = os2URL; | |
} else if (is_linux) { // Linux | |
//location.href = linuxURL; | |
} else if (is_win || is_win95 || is_win98 || is_winnt || is_win31 || is_win32 || is_win16) { | |
location.href = winURL; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment