//检测客户端环境 function ClientMentInfo() { var me = this; var appVer = navigator.userAgent; this.GetBrowserName = function (){ if(appVer.indexOf("MSIE")>0) return "IE"; else if(appVer.indexOf("Firefox")>0) return "Firefox"; else if(appVer.indexOf("Chrome")>0) return "Chrome"; else if(appVer.indexOf("Safari")>0) return "Safari"; else if(appVer.indexOf("Camino")>0) return "Camino"; else if(appVer.indexOf("Konqueror")>0) return "Konqueror"; else return "其它"; } this.GetOSInfo = function (){ var _pf = navigator.platform; if(_pf == "Win32" || _pf == "Windows") { if(appVer.indexOf("Windows NT 6.0") > -1 || appVer.indexOf("Windows Vista") > -1) { return 'Windows Vista'; }else if(appVer.indexOf("Windows NT 6.1") > -1 || appVer.indexOf("Windows 7") > -1) { return 'Windows 7'; }else { try{ var _winName = Array('2000','XP','2003'); var _ntNum = appVer.match(/Windows NT 5./d/i).toString(); return 'Windows ' + _winName[_ntNum.replace(/Windows NT 5.(/d)/i,"$1")]; }catch(e){return 'Windows';} } }else if(_pf == "Mac68K" || _pf == "MacPPC" || _pf == "Macintosh") { return "Mac"; }else if(_pf == "X11") { return "Unix"; }else if(String(_pf).indexOf("Linux") > -1) { return "Linux"; }else { return "Unknow"; } } this.OS = me.GetOSInfo(); //操作系统类型 this.IeVer = null; this.Bs_lang = (navigator.appName == 'Netscape'?navigator.language:navigator.browserLanguage);//浏览器语言版本 this.Bs_Name = me.GetBrowserName(); //浏览器名称 //浏览器版本 if(this.Bs_Name=='IE') { var _msie = appVer.match(/MSIE /d./i).toString(); this.Bs_Version = this.IeVer = _msie.replace(/MSIE (/d)./i,"$1"); }else { this.Bs_Version = appVer; } this.Ie6 = this.IeVer==6 ? true: false; this.Ie7 = this.IeVer==7 ? true: false; this.Ie8 = this.IeVer==8 ? true: false; } //客户端信息 var CMInfo = new ClientMentInfo(); 利用javascript来判断客户端操作系统和客户端浏览器类型的方法(2009-04-24更新,把它门改进为一个类)增加了对windows vista和windows 7的判断 (2009-06-02更新)