/ Published in: JavaScript
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function AuthObject() { var i, rvN; var UA = navigator.userAgent.toLowerCase(); this.ua = navigator.userAgent.toLowerCase(); // UserAgent in lowserCase this.isIE = false; // Is it Internet Explorer? this.isIE8 = false; // Is it Internet Explorer 8? this.isIE6 = false; // Is it Internet Explorer 6? this.isFF = false; // Is it Firfox? this.isSafari = false; // Is it Safari? this.isChrome = false; // Is it Chrome? this.isKonqueror = false; // Is it Konqueror? this.isOpera = false; // Is it Opera? this.isCamino = false; // Is it Camino? (A gecko-based browser on the Mac) this.isNav4 = false; // Is it Netscape Navigator 4? this.isGecko = false; // Is it a Gecko-based browser? (Mozilla Suite, Mozilla Firefox, Netscape 6+) this.ieVersion = null; // Internet Explorer version this.ffVersion = null; // Firefox Version this.operaVersion = null; // Opera Version this.webkitVersion = null; // WebKit Version this.geckoRevision = null; // Gecko revision this.geckoDate = null; // Gecko build date this.geckoRevisionMajor = null; // Gecko revision major version this.geckoRevisionMinor = null; // Gecko revision minor version this.isWin = false; // Is it Windows? this.isWinVista = false; // Is it Windows Vista? this.isMac = false; // Is it Mac? this.isLinux = false; // Is it Linux? //BROWSER AUTHENTICATION if(UA.indexOf("msie") >= 0){ this.isIE = true;} if((UA.indexOf('trident/4')>=0)||(UA.indexOf('msie 8')>=0)){ this.isIE8 = true;} if(UA.indexOf('msie 6')>=0){ this.isIE6 = true;} if(UA.indexOf("firefox") >= 0){ this.isFF = true;} if(UA.indexOf("safari") >= 0 && UA.indexOf("applewebkit") >=0 && UA.indexOf("version") >= 0){ this.isSafari = true;} if(UA.indexOf("chrome") >= 0 && UA.indexOf("applewebkit") >= 0 && UA.indexOf("safari")){ this.isChrome = true;} if(UA.indexOf("konqueror") >= 0){ this.isKonqueror = true;} if(UA.indexOf("opera") >= 0){ this.isOpera = true;} if(UA.indexOf("camino") >= 0){ this.isCamino = true;} if(UA.indexOf('mozilla')>=0 && UA.indexOf('compatible')==-1 && parseInt(navigator.appVersion)<5) { this.isNav4 = true;} if(UA.indexOf("gecko/") >= 0){ this.isGecko = true;} if(this.isIE){ this.ieVersion=UA.substr(UA.indexOf('msie')+5,3);} if(this.isOpera){ this.operaVersion=UA.substr(UA.indexOf('opera')+6,4);} if(UA.indexOf("applewebkit/") >= 0){ i = UA.indexOf("applewebkit/"); this.webkitVersion = parseFloat(UA.substr(i + 12));} if(UA.indexOf("firefox/") >= 0){ i = UA.indexOf("firefox/"); this.ffVersion = parseFloat(UA.substr(i + 8)) ;} rvN = "rv:"; if(this.isGecko){ i = UA.indexOf(rvN) var geckoRevisionStr = UA.substr(i + rvN.length); this.geckoRevision=parseFloat(UA.substr(i + rvN.length)); this.geckoDate=parseFloat(UA.substr(UA.indexOf("gecko/")+6)); this.geckoRevisionMajor=parseFloat(geckoRevisionStr.split(".")); this.geckoRevisionMinor=parseFloat(geckoRevisionStr.split(".")[1]+ "."+geckoRevisionStr.split(".")[2]);} //OS AUTHENTICATION if(UA.indexOf("windows") >= 0 && UA.indexOf("windows nt 6.0") <= 0){ this.isWin = true;} if(UA.indexOf("windows nt 6.0") >=0){ this.isWinVista = true;} if(UA.indexOf("mac") >=0){ this.isMac = true;} if(UA.indexOf('linux')>=0){ this.isLinux = true;} } var Auth = new AuthObject();