Home » Tutorials » Dreamweaver
| Note: This tutorial is done by Macromedia
Dreamweaver MX. |
| Intro: This tutorial will teach you how
to make a script that will redirect users based on their browser
type to different pages or url. It is restricted to two browser
types only which are Internet Explorer and Netscape Navigator.
You are not going to learn how to write this script, but learn
how to use Dreamweaver to make such a script. |
First open Dreamweaver and make a new page. Go to Window
> Behaviors if your behaviors panel is
not open. Then click on the +
sign and choose Check Browser

|
You will be shown this window when you choose the Check
Browser Option.

Here you should make your choices, I have chosen here if
the Browser is:
Netscapte Navigator 4.0 and later
- go to www.yahoo.com and if it is Netscape
Navigator < 4.0 - go to www.google.com
After you make your selection Click OK |
Make sure onLoad option
is chosen under the Events, we want users to be redirected
when this page loads.

You are done, preview your page and see where you are redirected
based on your Browser Type. |
|
|
You could as well redirect all the users who are using Netscape
Navigator to one page and Internet Explorer user to other.
This way if you have two versions of you website for specific
browser types, you could redirect them to respectie pages
which are viewed best by their specific browser types. It
is matter of how you use this script.
|
Another option is redirect all four options to one page,
then it would become a normal redirection script that redirects
all the users to one specific page.
|
Here is the code that is generated
by Dreamweaver after this tutorial:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD
HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_checkBrowser(NSvers,NSpass,NSnoPass,IEvers,IEpass,IEnoPass,OBpass,URL,altURL)
{ //v4.0
var newURL='', verStr=navigator.appVersion, app=navigator.appName,
version = parseFloat(verStr);
if (app.indexOf('Netscape') != -1) {
if (version >= NSvers) {if (NSpass>0) newURL=(NSpass==1)?URL:altURL;}
else {if (NSnoPass>0) newURL=(NSnoPass==1)?URL:altURL;}
} else if (app.indexOf('Microsoft') != -1) {
if (version >= IEvers || verStr.indexOf(IEvers) != -1)
{if (IEpass>0) newURL=(IEpass==1)?URL:altURL;}
else {if (IEnoPass>0) newURL=(IEnoPass==1)?URL:altURL;}
} else if (OBpass>0) newURL=(OBpass==1)?URL:altURL;
if (newURL) { window.location=unescape(newURL); document.MM_returnValue=false;
}
}
//-->
</script>
</head>
<body onLoad="MM_checkBrowser(4.0,1,2,4.0,1,2,2,'www.yahoo.com','www.google.com');return
document.MM_returnValue">
</body>
</html>
 |
Related Dreamweaver Tutorials |
| |
 |
How to backup Dreamweaver New
Backup your templates, extensions, behaviors...etc |
| |
 |
Creating CSS in Dreamweaver MX 2004
Learn how to create and apply CSS in Dreamweaver |
| |
 |
Create Rollover/MouseOver effect
Rollover effect made easy with Dreamweaver |
| |
 |
Opening a Fixed Size Window
Learn how to open a window in a fixed size |
| |
 |
Redirection based on Browser Type
Learn how to make redirection script with Dreamweaver |
| |
|
|
|
 |
|