//Source for this code came from: http://www.builder.com/Authoring/Dhtml/ss03b.html // The ultimate client sniffer // (C) Netscape Communications 1998. Permission granted to reuse and distribute. // Everything you always wanted to know about your JavaScript client // but were afraid to ask... The "is" constructor function for the Is object // has properties indicating: // 1. browser vendor: // is.nav, is.ie, is.opera // 2. browser version number: // is.major (integer indicating major version number: 2, 3, 4 ...) // is.minor (float indicating full version number: 2.02, 3.01, 4.04 ...) // 3. browser vendor and major version number // is.nav2, is.nav3, is.nav4, is.ie3, is.ie4 // 4. JavaScript version number: // is.js (float indicating full JavaScript version number: 1, 1.1, 1.2 ...) // 5. OS platform and version: // is.win, is.win16, is.win32, is.win31, is.win95, is.winnt, is.win98 // is.os2 // is.mac, is.mac68k, is.macppc // is.unix // is.sun, is.sun4, is.sun5, is.suni86 // is.irix, is.irix5, is.irix6 // is.hpux, is.hpux9, is.hpux10 // is.aix, is.aix1, is.aix2, is.aix3, is.aix4 // is.linux, is.sco, is.unixware, is.mpras, is.reliant // is.dec, is.sinix, is.freebsd, is.bsd // is.vms // // See http://home.kiss.de/~i_thum/JS_tutorial/bstat/navobj.html // for a detailed list of userAgent strings. function Is () { // convert all characters to lowercase to simplify testing var agt=navigator.userAgent.toLowerCase() // *** BROWSER VERSION *** this.major = parseInt(navigator.appVersion) this.minor = parseFloat(navigator.appVersion) this.nav = ((agt.indexOf('mozilla')!=-1) && ((agt.indexOf('spoofer')==-1) && (agt.indexOf('compatible') == -1))) this.nav2 = (this.nav && (this.major == 2)) this.nav3 = (this.nav && (this.major == 3)) this.nav4 = (this.nav && (this.major == 4)) this.navonly = (this.nav && (agt.indexOf(";nav") != -1)) this.ie = (agt.indexOf("msie") != -1) this.ie3 = (this.ie && (this.major == 2)) this.ie4 = (this.ie && (this.major == 4)) this.opera = (agt.indexOf("opera") != -1) // *** JAVASCRIPT VERSION CHECK *** // Useful to workaround Navigator 3.0 bug, in which the browser // loads
Make your own free website on Tripod.com
Client Sniffer: Determines exactly what's on the client end. The ultimate client sniffer The sample code presented here lets you detect the browser's vendor, version number, and operating system. The script creates an object called is that has properties indicating the browser's vendor, version number, JavaScript version number, and operating system. It has been tested on a variety of browser-platform combinations, including: Navigator 2.0, 3.0, and 4.0 on Macintosh, Windows 95 and NT, and SunOS5; IE 3.0 and 4.0 on Windows 95 and NT; and Opera 3.0 on Windows 95 and NT. It should work with all JavaScript-capable browser versions on all platforms. After you have checked the browser vendor and version, you can dynamically generate optimized HTML markup, and your JavaScript code can conditionally branch to execute JavaScript optimized for the dynamically generated page or the current browser.