// In the case of an error, we suppress the error message. function stopError() { return true; } window.onerror = stopError; // Set variables that will eventually write our link tag. var linkopen = ''; var linkfile // This will be the name of the specific CSS file we determine is right for this browser. // Get the browser name and basic version information, converted to all lower case to simplify testing. var agt = navigator.userAgent.toLowerCase(); var appVer = navigator.appVersion.toLowerCase(); // Determine the browser version, and point release. var is_minor = parseFloat(appVer); var is_major = parseInt(is_minor); // Internet Explorer always returns version 3 or 4 in the appVersion. We look further in the appVersion string for the actual version number. var iePos = appVer.indexOf('msie'); if (iePos != -1) { is_minor = parseFloat(appVer.substring(iePos+5,appVer.indexOf(';',iePos))); is_major = parseInt(is_minor); } // Netscape 6 and Mozilla always return version 5 in the appVersion. We look further in the appVersion string for the actual version number. var nav6Pos = agt.indexOf('netscape6'); if (nav6Pos !=-1) { is_minor = parseFloat(agt.substring(nav6Pos+10)); is_major = parseInt(is_minor); } // The actual detection of the browser occurs here. // is_nav is set to true if this is a Netscape or the Mozilla browser. var is_nav = ((agt.indexOf('mozilla') != -1) && (agt.indexOf('spoofer') == -1) && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera') == -1) && (agt.indexOf('webtv') == -1)); // is_nav4 is set to true if this is Netscape 4. var is_nav4 = (is_nav && (is_major == 4)); // is_nav6up is set to true if this is Netscape 6 or better (allows for future version 7+ releases) or the Mozilla browser. // Testing is_minor for 5+ allows for the actual Mozilla browser to use the Netscape 6 CSS, since Mozilla reports itself as version 5. // To exclude Mozilla, test is_minor for 6+. var is_nav6up = (is_nav && is_minor >= 5); // is_ie is set to true if this is the Internet Explorer browser. var is_ie = (iePos != -1); // ie_ie4up is set to true if this is Internet Explorer 4 or better (allows for future version 6+ releases). var is_ie4up = (is_ie && is_minor >= 4); // is_opera is set to true if this is the Opera browser. var is_opera = (agt.indexOf('opera') != -1); // Which (if any) CSS file we should write a link to is determined here. if (is_nav) { // If this is Netscape or Mozilla.... if (is_nav4) { // If this is Netscape 4.... linkfile = 'nn4'; } if (is_nav6up) { // If this is Netscape 6 or better, or Mozilla.... linkfile = 'nn6'; } } if (is_ie) { // If this is Internet Explorer.... if (is_ie4up) { // If this is Internet Explorer 4 or better.... linkfile = 'ie4'; } } if (is_opera) { // If this is Opera.... linkfile = 'op3'; } // If an appropriate CSS file has been determined, write a link to it into the HTML if (linkfile) { var linkhtml = linkopen + linkfile + linkclose; document.write(linkhtml); }