当前位置: 首页 > 网络学院 > 网页制作基础教程 > WEB设计综合 > 基于浏览器类型实现页面的重定向

WEB设计综合
如何设置滚动条的样式?
鼠标经过改变表格背景属性
关闭IE中探出的图形工具栏
去掉链接中的下划线
CSS 常用布局
Meta 标签
自动刷新、转向
除去打印脚本
IP阻止
指针样式
定义滚动条样式
链接效果
框架中的“target”
开启DW中的无效行为
IFrames 简介
透明 IFrames
超链接效果
基于浏览器类型实现页面的重定向
HTML基本原则
图像边框

WEB设计综合 中的 基于浏览器类型实现页面的重定向


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-03-01   浏览: 1884 ::
收藏到网摘: n/a

Note: This tutorial is done by Macromedia Dreamweaver MX.

提示:这篇教程是通过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.

介绍:这篇教程将教会你如何创建一个基于不同浏览器类型来实现页面定位的脚本程序。它只限制于两种不同的浏览器,IENetscape。你不需要学习如何书写这段脚本程序,你只需要知道如何使用Dreamweaver来创建这个脚本程序就可以了。

1. 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

首先,打开Dreamweaver并新建一个页面。如何你的“行为”面板没有打开,那么请选择“窗口”—“行为”,此时,点击“+”号并选择“检查浏览器

redirect 1

2. You will be shown this window when you choose the Check BrowserOption.

此时,当你选择了“检查浏览器”之后,将会看见下面这张菜单。

redirect 2

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

如果是Netscapte 4.0或以上版本,那么访问www.yahoo.com,如果版本低于4.0,那么访问www.google.com

After you make your selection Click OK

完成之后点击“确定”。

3. Make sure onLoad option is chosen under the Events, we want users to be redirected when this page loads.

确保已经选择了onload事件,我们希望在用户家在页面时作出定位。

redirect 3

You are done, preview your page and see where you are redirected based on your Browser Type.

当你完成后,你就可以看看,基于你的浏览器类型,你将访问那一个网站

4. 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.

你也可以对使用NetscapeIE的用户所对应的访问地址进行定义。如果你的网站针对这两种浏览器分别包含两种不同的版本,那么,你就可以使用这个方法;你可以根据用户浏览器版本的不同,分别指定不同的访问页面,以达到最佳的浏览效果。在这种情况下,使用这个脚本程序就非常重要。

5. 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:

下面列举的是由Dreamweaver产生的脚本程序:

<!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>

评论 (0) All

登陆 | 还没注册?