Browser Detection

This script loads a page based on the browser being used. It detects: Netscape 3.x, Netscape 4.x, Netscape 5.x, Microsoft 3.x, Microsoft 4.x and Microsoft 5.x.


<html>
<script language="JavaScript">
<!-- hide
  //  Script:       Browser Detection
  //  Version:      1.3
  //  Last Updated: November 1st 1998
  //  Author:       Scott Brady
  //  Org:          HotSource HTML Help
  //  Email:        webmaster at sbrady dot com
  //  Website:      http://www.sbrady.com/hotsource/

var browser=navigator.appName;
var version=navigator.appVersion;

// Load page according to browser
function loadPage() {
   // find which browser it is
   if (browser.indexOf("Netscape") >= 0) {
      // find which version
      if (version.indexOf("3.") >= 0) {
         window.location="netscape3.html";
      }
      if (version.indexOf("4.") >= 0) {
         window.location="netscape4.html";
      }
      if (version.indexOf("5.") >= 0) {
         window.location="netscape5.html";
      }
   }

   if (browser.indexOf("Microsoft") >= 0) {
      // find which version
      if (version.indexOf("3.") >= 0) {
         window.location="microsoft3.html";
      }
      if (version.indexOf("4.") >= 0) {
         window.location="microsoft4.html";
      }
      if (version.indexOf("5.") >= 0) {
         window.location="microsoft5.html";
      }
   }
}
// stop hiding -->
</script>

<head>
<title>The auto detect browser script</title>
</head>
<body onLoad="loadPage();">
etc...

Notes:

  1. Change the page addresses to the correct URLs.
  2. To ensure the code is copied correctly, please click here.

See it in action.