Browser Detection :
EXAMPLE








In this example we send Netscape visitors to Yahoo, while we send MSIE visitors to either Hotbot or MSN depending on the browser version.
If it's none of the above the visitor is sent to Webcrawler.

BROWSER DETECTION SCRIPT
- with if statements

<html>
<head>
<title>Browser detection</Title>
<Script Language="JavaScript">
// Browserdetectionscript made by Henrik Petersen / NetKontoret
// Script explained at www.echoecho.com/javascript.htm
// Please do not remove this and the two lines above.
// Detect the browsername
browsername=navigator.appName;
if (browsername.indexOf("Netscape")!=-1) {browsername="NS"}
else
{if (browsername.indexOf("Microsoft")!=-1) {browsername="MSIE"}
else {browsername="N/A"}};

//detect the browserversion
browserversion="0";
if (navigator.appVersion.indexOf("2.")!=-1) {browserversion="2"};
if (navigator.appVersion.indexOf("3.")!=-1) {browserversion="3"};
if (navigator.appVersion.indexOf("4.")!=-1) {browserversion="4"};
if (navigator.appVersion.indexOf("5.")!=-1) {browserversion="5"};
if (navigator.appVersion.indexOf("6.")!=-1) {browserversion="6"};

// Send visitor to relevant pages
if (browsername=="NS") {window.location="http://www.yahoo.com"};
if (browsername=="MSIE"){
  if (browserversion<4){window.location="http://www.hotbot.com"}
  else {window.location="http://www.msn.com"}
}
if (browsername=="N/A") {window.location="http://www.webcrawler.com"};

</script>
</head>

<body>
</body>
</html>


Copy the code from this example to create your own browser detection page.

Customize it by adding your own if statements and URLs at the bottom of the script.




SAMPLE PAGE
Click here to see a sample page based on the code described above.

 << PREVIOUS
BACK TO MENU >>  
















DEVELOPER TIP!





     "Better Than Books - As Easy As It Gets!"