[903] | 1 | //<!-- |
---|
| 2 | // Ultimate client-side JavaScript client sniff. Version 3.03 |
---|
| 3 | // (C) Netscape Communications 1999-2001. Permission granted to reuse and distribute. |
---|
| 4 | // Revised 17 May 99 to add is_nav5up and is_ie5up (see below). |
---|
| 5 | // Revised 20 Dec 00 to add is_gecko and change is_nav5up to is_nav6up |
---|
| 6 | // also added support for IE5.5 Opera4&5 HotJava3 AOLTV |
---|
| 7 | // Revised 22 Feb 01 to correct Javascript Detection for IE 5.x, Opera 4, |
---|
| 8 | // correct Opera 5 detection |
---|
| 9 | // add support for winME and win2k |
---|
| 10 | // synch with browser-type-oo.js |
---|
| 11 | // Revised 26 Mar 01 to correct Opera detection |
---|
| 12 | // Revised 02 Oct 01 to add IE6 detection |
---|
| 13 | |
---|
| 14 | // Everything you always wanted to know about your JavaScript client |
---|
| 15 | // but were afraid to ask. Creates "is_" variables indicating: |
---|
| 16 | // (1) browser vendor: |
---|
| 17 | // is_nav, is_ie, is_opera, is_hotjava, is_webtv, is_TVNavigator, is_AOLTV |
---|
| 18 | // (2) browser version number: |
---|
| 19 | // is_major (integer indicating major version number: 2, 3, 4 ...) |
---|
| 20 | // is_minor (float indicating full version number: 2.02, 3.01, 4.04 ...) |
---|
| 21 | // (3) browser vendor AND major version number |
---|
| 22 | // is_nav2, is_nav3, is_nav4, is_nav4up, is_nav6, is_nav6up, is_gecko, is_ie3, |
---|
| 23 | // is_ie4, is_ie4up, is_ie5, is_ie5up, is_ie5_5, is_ie5_5up, is_ie6, is_ie6up, is_hotjava3, is_hotjava3up, |
---|
| 24 | // is_opera2, is_opera3, is_opera4, is_opera5, is_opera5up |
---|
| 25 | // (4) JavaScript version number: |
---|
| 26 | // is_js (float indicating full JavaScript version number: 1, 1.1, 1.2 ...) |
---|
| 27 | // (5) OS platform and version: |
---|
| 28 | // is_win, is_win16, is_win32, is_win31, is_win95, is_winnt, is_win98, is_winme, is_win2k |
---|
| 29 | // is_os2 |
---|
| 30 | // is_mac, is_mac68k, is_macppc |
---|
| 31 | // is_unix |
---|
| 32 | // is_sun, is_sun4, is_sun5, is_suni86 |
---|
| 33 | // is_irix, is_irix5, is_irix6 |
---|
| 34 | // is_hpux, is_hpux9, is_hpux10 |
---|
| 35 | // is_aix, is_aix1, is_aix2, is_aix3, is_aix4 |
---|
| 36 | // is_linux, is_sco, is_unixware, is_mpras, is_reliant |
---|
| 37 | // is_dec, is_sinix, is_freebsd, is_bsd |
---|
| 38 | // is_vms |
---|
| 39 | // |
---|
| 40 | // See http://www.it97.de/JavaScript/JS_tutorial/bstat/navobj.html and |
---|
| 41 | // http://www.it97.de/JavaScript/JS_tutorial/bstat/Browseraol.html |
---|
| 42 | // for detailed lists of userAgent strings. |
---|
| 43 | // |
---|
| 44 | // Note: you don't want your Nav4 or IE4 code to "turn off" or |
---|
| 45 | // stop working when new versions of browsers are released, so |
---|
| 46 | // in conditional code forks, use is_ie5up ("IE 5.0 or greater") |
---|
| 47 | // is_opera5up ("Opera 5.0 or greater") instead of is_ie5 or is_opera5 |
---|
| 48 | // to check version in code which you want to work on future |
---|
| 49 | // versions. |
---|
| 50 | |
---|
| 51 | // convert all characters to lowercase to simplify testing |
---|
| 52 | var agt=navigator.userAgent.toLowerCase(); |
---|
| 53 | |
---|
| 54 | // *** BROWSER VERSION *** |
---|
| 55 | // Note: On IE5, these return 4, so use is_ie5up to detect IE5. |
---|
| 56 | var is_major = parseInt(navigator.appVersion); |
---|
| 57 | var is_minor = parseFloat(navigator.appVersion); |
---|
| 58 | |
---|
| 59 | // Note: Opera and WebTV spoof Navigator. We do strict client detection. |
---|
| 60 | // If you want to allow spoofing, take out the tests for opera and webtv. |
---|
| 61 | var is_nav = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1) |
---|
| 62 | && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1) |
---|
| 63 | && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1)); |
---|
| 64 | var is_nav2 = (is_nav && (is_major == 2)); |
---|
| 65 | var is_nav3 = (is_nav && (is_major == 3)); |
---|
| 66 | var is_nav4 = (is_nav && (is_major == 4)); |
---|
| 67 | var is_nav4up = (is_nav && (is_major >= 4)); |
---|
| 68 | var is_navonly = (is_nav && ((agt.indexOf(";nav") != -1) || |
---|
| 69 | (agt.indexOf("; nav") != -1)) ); |
---|
| 70 | var is_nav6 = (is_nav && (is_major == 5)); |
---|
| 71 | var is_nav6up = (is_nav && (is_major >= 5)); |
---|
| 72 | var is_gecko = (agt.indexOf('gecko') != -1); |
---|
| 73 | |
---|
| 74 | |
---|
| 75 | var is_ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1)); |
---|
| 76 | var is_ie3 = (is_ie && (is_major < 4)); |
---|
| 77 | var is_ie4 = (is_ie && (is_major == 4) && (agt.indexOf("msie 4")!=-1) ); |
---|
| 78 | var is_ie4up = (is_ie && (is_major >= 4)); |
---|
| 79 | var is_ie5 = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")!=-1) ); |
---|
| 80 | var is_ie5_5 = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.5") !=-1)); |
---|
| 81 | var is_ie5up = (is_ie && !is_ie3 && !is_ie4); |
---|
| 82 | var is_ie5_5up =(is_ie && !is_ie3 && !is_ie4 && !is_ie5); |
---|
| 83 | var is_ie6 = (is_ie && (is_major == 4) && (agt.indexOf("msie 6.")!=-1) ); |
---|
| 84 | var is_ie6up = (is_ie && !is_ie3 && !is_ie4 && !is_ie5 && !is_ie5_5); |
---|
| 85 | |
---|
| 86 | // KNOWN BUG: On AOL4, returns false if IE3 is embedded browser |
---|
| 87 | // or if this is the first browser window opened. Thus the |
---|
| 88 | // variables is_aol, is_aol3, and is_aol4 aren't 100% reliable. |
---|
| 89 | var is_aol = (agt.indexOf("aol") != -1); |
---|
| 90 | var is_aol3 = (is_aol && is_ie3); |
---|
| 91 | var is_aol4 = (is_aol && is_ie4); |
---|
| 92 | var is_aol5 = (agt.indexOf("aol 5") != -1); |
---|
| 93 | var is_aol6 = (agt.indexOf("aol 6") != -1); |
---|
| 94 | |
---|
| 95 | var is_opera = (agt.indexOf("opera") != -1); |
---|
| 96 | var is_opera2 = (agt.indexOf("opera 2") != -1 || agt.indexOf("opera/2") != -1); |
---|
| 97 | var is_opera3 = (agt.indexOf("opera 3") != -1 || agt.indexOf("opera/3") != -1); |
---|
| 98 | var is_opera4 = (agt.indexOf("opera 4") != -1 || agt.indexOf("opera/4") != -1); |
---|
| 99 | var is_opera5 = (agt.indexOf("opera 5") != -1 || agt.indexOf("opera/5") != -1); |
---|
| 100 | var is_opera5up = (is_opera && !is_opera2 && !is_opera3 && !is_opera4); |
---|
| 101 | |
---|
| 102 | var is_webtv = (agt.indexOf("webtv") != -1); |
---|
| 103 | |
---|
| 104 | var is_TVNavigator = ((agt.indexOf("navio") != -1) || (agt.indexOf("navio_aoltv") != -1)); |
---|
| 105 | var is_AOLTV = is_TVNavigator; |
---|
| 106 | |
---|
| 107 | var is_hotjava = (agt.indexOf("hotjava") != -1); |
---|
| 108 | var is_hotjava3 = (is_hotjava && (is_major == 3)); |
---|
| 109 | var is_hotjava3up = (is_hotjava && (is_major >= 3)); |
---|
| 110 | |
---|
| 111 | // *** JAVASCRIPT VERSION CHECK *** |
---|
| 112 | var is_js; |
---|
| 113 | if (is_nav2 || is_ie3) is_js = 1.0; |
---|
| 114 | else if (is_nav3) is_js = 1.1; |
---|
| 115 | else if (is_opera5up) is_js = 1.3; |
---|
| 116 | else if (is_opera) is_js = 1.1; |
---|
| 117 | else if ((is_nav4 && (is_minor <= 4.05)) || is_ie4) is_js = 1.2; |
---|
| 118 | else if ((is_nav4 && (is_minor > 4.05)) || is_ie5) is_js = 1.3; |
---|
| 119 | else if (is_hotjava3up) is_js = 1.4; |
---|
| 120 | else if (is_nav6 || is_gecko) is_js = 1.5; |
---|
| 121 | // NOTE: In the future, update this code when newer versions of JS |
---|
| 122 | // are released. For now, we try to provide some upward compatibility |
---|
| 123 | // so that future versions of Nav and IE will show they are at |
---|
| 124 | // *least* JS 1.x capable. Always check for JS version compatibility |
---|
| 125 | // with > or >=. |
---|
| 126 | else if (is_nav6up) is_js = 1.5; |
---|
| 127 | // NOTE: ie5up on mac is 1.4 |
---|
| 128 | else if (is_ie5up) is_js = 1.3; |
---|
| 129 | |
---|
| 130 | // HACK: no idea for other browsers; always check for JS version with > or >= |
---|
| 131 | else is_js = 0.0; |
---|
| 132 | |
---|
| 133 | // *** PLATFORM *** |
---|
| 134 | var is_win = ( (agt.indexOf("win")!=-1) || (agt.indexOf("16bit")!=-1) ); |
---|
| 135 | // NOTE: On Opera 3.0, the userAgent string includes "Windows 95/NT4" on all |
---|
| 136 | // Win32, so you can't distinguish between Win95 and WinNT. |
---|
| 137 | var is_win95 = ((agt.indexOf("win95")!=-1) || (agt.indexOf("windows 95")!=-1)); |
---|
| 138 | |
---|
| 139 | // is this a 16 bit compiled version? |
---|
| 140 | var is_win16 = ((agt.indexOf("win16")!=-1) || |
---|
| 141 | (agt.indexOf("16bit")!=-1) || (agt.indexOf("windows 3.1")!=-1) || |
---|
| 142 | (agt.indexOf("windows 16-bit")!=-1) ); |
---|
| 143 | |
---|
| 144 | var is_win31 = ((agt.indexOf("windows 3.1")!=-1) || (agt.indexOf("win16")!=-1) || |
---|
| 145 | (agt.indexOf("windows 16-bit")!=-1)); |
---|
| 146 | |
---|
| 147 | var is_winme = ((agt.indexOf("win 9x 4.90")!=-1)); |
---|
| 148 | var is_win2k = ((agt.indexOf("windows nt 5.0")!=-1)); |
---|
| 149 | |
---|
| 150 | // NOTE: Reliable detection of Win98 may not be possible. It appears that: |
---|
| 151 | // - On Nav 4.x and before you'll get plain "Windows" in userAgent. |
---|
| 152 | // - On Mercury client, the 32-bit version will return "Win98", but |
---|
| 153 | // the 16-bit version running on Win98 will still return "Win95". |
---|
| 154 | var is_win98 = ((agt.indexOf("win98")!=-1) || (agt.indexOf("windows 98")!=-1)); |
---|
| 155 | var is_winnt = ((agt.indexOf("winnt")!=-1) || (agt.indexOf("windows nt")!=-1)); |
---|
| 156 | var is_win32 = (is_win95 || is_winnt || is_win98 || |
---|
| 157 | ((is_major >= 4) && (navigator.platform == "Win32")) || |
---|
| 158 | (agt.indexOf("win32")!=-1) || (agt.indexOf("32bit")!=-1)); |
---|
| 159 | |
---|
| 160 | var is_os2 = ((agt.indexOf("os/2")!=-1) || |
---|
| 161 | (navigator.appVersion.indexOf("OS/2")!=-1) || |
---|
| 162 | (agt.indexOf("ibm-webexplorer")!=-1)); |
---|
| 163 | |
---|
| 164 | var is_mac = (agt.indexOf("mac")!=-1); |
---|
| 165 | // hack ie5 js version for mac |
---|
| 166 | if (is_mac && is_ie5up) is_js = 1.4; |
---|
| 167 | var is_mac68k = (is_mac && ((agt.indexOf("68k")!=-1) || |
---|
| 168 | (agt.indexOf("68000")!=-1))); |
---|
| 169 | var is_macppc = (is_mac && ((agt.indexOf("ppc")!=-1) || |
---|
| 170 | (agt.indexOf("powerpc")!=-1))); |
---|
| 171 | |
---|
| 172 | var is_sun = (agt.indexOf("sunos")!=-1); |
---|
| 173 | var is_sun4 = (agt.indexOf("sunos 4")!=-1); |
---|
| 174 | var is_sun5 = (agt.indexOf("sunos 5")!=-1); |
---|
| 175 | var is_suni86= (is_sun && (agt.indexOf("i86")!=-1)); |
---|
| 176 | var is_irix = (agt.indexOf("irix") !=-1); // SGI |
---|
| 177 | var is_irix5 = (agt.indexOf("irix 5") !=-1); |
---|
| 178 | var is_irix6 = ((agt.indexOf("irix 6") !=-1) || (agt.indexOf("irix6") !=-1)); |
---|
| 179 | var is_hpux = (agt.indexOf("hp-ux")!=-1); |
---|
| 180 | var is_hpux9 = (is_hpux && (agt.indexOf("09.")!=-1)); |
---|
| 181 | var is_hpux10= (is_hpux && (agt.indexOf("10.")!=-1)); |
---|
| 182 | var is_aix = (agt.indexOf("aix") !=-1); // IBM |
---|
| 183 | var is_aix1 = (agt.indexOf("aix 1") !=-1); |
---|
| 184 | var is_aix2 = (agt.indexOf("aix 2") !=-1); |
---|
| 185 | var is_aix3 = (agt.indexOf("aix 3") !=-1); |
---|
| 186 | var is_aix4 = (agt.indexOf("aix 4") !=-1); |
---|
| 187 | var is_linux = (agt.indexOf("inux")!=-1); |
---|
| 188 | var is_sco = (agt.indexOf("sco")!=-1) || (agt.indexOf("unix_sv")!=-1); |
---|
| 189 | var is_unixware = (agt.indexOf("unix_system_v")!=-1); |
---|
| 190 | var is_mpras = (agt.indexOf("ncr")!=-1); |
---|
| 191 | var is_reliant = (agt.indexOf("reliantunix")!=-1); |
---|
| 192 | var is_dec = ((agt.indexOf("dec")!=-1) || (agt.indexOf("osf1")!=-1) || |
---|
| 193 | (agt.indexOf("dec_alpha")!=-1) || (agt.indexOf("alphaserver")!=-1) || |
---|
| 194 | (agt.indexOf("ultrix")!=-1) || (agt.indexOf("alphastation")!=-1)); |
---|
| 195 | var is_sinix = (agt.indexOf("sinix")!=-1); |
---|
| 196 | var is_freebsd = (agt.indexOf("freebsd")!=-1); |
---|
| 197 | var is_bsd = (agt.indexOf("bsd")!=-1); |
---|
| 198 | var is_unix = ((agt.indexOf("x11")!=-1) || is_sun || is_irix || is_hpux || |
---|
| 199 | is_sco ||is_unixware || is_mpras || is_reliant || |
---|
| 200 | is_dec || is_sinix || is_aix || is_linux || is_bsd || is_freebsd); |
---|
| 201 | |
---|
| 202 | var is_vms = ((agt.indexOf("vax")!=-1) || (agt.indexOf("openvms")!=-1)); |
---|
| 203 | |
---|
| 204 | //--> end hide JavaScript |
---|