|
This script checks which browser version the visitor is
using and automatically redirects the user to the appropriate page. The best site
will appear if you are using the latest browser. Click on the link below for an
example. This example displays a small message and waits 3 seconds before
redirecting the user with the function browsercheck( ).
Sample Redirect
| Back to Web Tips
<body onload="timeoutID=setTimeout('browsercheck( )',
3000)">
<p>Welcome to the 95Net Support page. In
3 seconds, this page will determine which browser you are currently using.</p>
<script
language="JavaScript">
<!--
function browsercheck( ) {
bName = navigator.appName;
bVer = parseInt(navigator.appVersion);
if (bName ==
"Netscape" && bVer == 2) ver = "n2";
else if (bName == "Netscape" && bVer == 3) ver = "n3";
else if (bName == "Netscape" && bVer == 4) ver = "n4";
else if (bName == "Microsoft Internet Explorer" && bVer <2) ver =
"n2";
else if (bName == "Microsoft Internet Explorer" && bVer ==2) ver =
"n3";
else if (bName == "Microsoft Internet Explorer" && bVer > 2) ver =
"n4";
if (ver == "n2") {
location="vanilla.htm"
}
else if (ver=="n3") {
location="rockyroad.htm"
}
else {
location="hotfudgesundae.htm"
}
}
//-->
</script>
- The if / else statements can be
modified or generalized as necessary.
- You can use different equality checks for more control. The
valid conditional operators are:
equal (==), not equal (!=), greater than (>), less than (<),
greater than or equal (>=), and less than or equal (<=)
- The script should generally be used
in a splash or introductory page.
Back to Web Tips |