JS Judging window OS 1
functionDetectos () {varSuseragent =navigator.useragent; varIswin = (Navigator.platform = = "Win32") | | (Navigator.platform = = "Windows"); varIsmac = (Navigator.platform = = "mac68k") | | (Navigator.platform = = "MacPPC") | | (Navigator.platform = = "Macintosh") | | (Navigator.platform = = "Macintel"); if(ISMAC)return"Mac"; varIsunix = (Navigator.platform = = "X11") &&!iswin &&!Ismac; if(Isunix)return"Unix"; varIslinux = (String (navigator.platform). IndexOf ("Linux") >-1); if(Islinux)return"Linux"; if(Iswin) {varIswin2k = Suseragent.indexof ("Windows NT 5.0") >-1 | | Suseragent.indexof ("Windows $") >-1; if(iswin2k)return"Win2000"; varISWINXP = Suseragent.indexof ("Windows NT 5.1") >-1 | | Suseragent.indexof ("Windows XP") >-1; if(ISWINXP)return"WinXP"; varisWin2003 = Suseragent.indexof ("Windows NT 5.2") >-1 | | Suseragent.indexof ("Windows 2003") >-1; if(isWin2003)return"Win2003"; varIswinvista= suseragent.indexof ("Windows NT 6.0") >-1 | | Suseragent.indexof ("Windows Vista") >-1; if(Iswinvista)return"WinVista"; varisWin7 = Suseragent.indexof ("Windows NT 6.1") >-1 | | Suseragent.indexof ("Windows 7") >-1; if(isWin7)return"Win7"; } return"Other";} Document.writeln ("Your operating system is:" +Detectos ());
JS Judging window OS 2
functionmobile_device_detect (URL) {varthisos=Navigator.platform; varos=NewArray ("IPhone", "IPod", "IPad", "Android", "Nokia", "SymbianOS", "Symbian", "Windows Phone", "Phone", "Linux armv71", " MAUI "," untrusted/1.0 "," Windows CE "," BlackBerry "," Iemobile "); for(vari=0;i<os.length;i++){ if(Thisos.match (Os[i])) {window.location=URL; } } if(Navigator.platform.indexOf (' IPad ')! =-1) {window.location=URL; } varCheck =navigator.appversion; if(Check.match (/linux/i)) {if(Check.match (/mobile/i) | | Check.match (/x11/i)) {window.location=URL; }} Array.prototype.in_array=function(e) { for(i=0;i< This. length;i++){ if( This[I] = =e)return true; } return false; } } varDomain =Document.domain; if(domain== ' qcj.haodai05.cn ') {Mobile_device_detect ("/http" +domain+ "/mobile"); } if(domain== ' qcj.hxtz198.cn ') {Mobile_device_detect ("/http" +domain+ "/mobile"); } if(domain== ' qcj.hxtz78.cn ') {Mobile_device_detect ("/http" +domain+ "/mobile"); } mobile_device_detect ("Http://www.qcj18.com/mobile");
2 Methods of JS judging window operating system