帮助 - 基于操作系统重定向 [英] HELP - Re-direct based on OS
问题描述
我正在尝试创建一个基于他们的操作系统重定向用户的网站。
对于这个网站,我需要将NT4和95用户发送到网站A和2000 / XP
用户到站点B.
所有其他人应该被定向到站点B.
提前致谢。
Rich
navigator.userAgent将提供有关使用过的操作系统的一些信息
micha
这应该可以完成这项工作,它实际上区分了比你需要的更多平台
,只需删除不必要的行。
-alu
__________________________________________________ _
var n = navigator;
var ua = '''''+ n.userAgent.toLowerCase();
//找到Windows平台
var is_win = ua.indexOf(' 'win'')> 0;
var is_win16 =(ua.indexOf('''16'')> 0& ua.indexOf(''win'')> 0);
var is_win31 = is_win16;
var is_win95 =(ua.indexOf(''95'')> 0& ua.indexOf(''win'')> 0);
var is_win98 =(ua.indexOf('''98'')> 0& ua.indexOf(''win'')> 0);
var is_winnt =(ua.indexOf(''nt'')> 0& ua.indexOf(''win'')> 0);
var is_winnt4 =(ua.indexOf(''nt 4.0'')> 0& ua.indexOf(''win'')> 0);
//去雅虎if NT4或win95,否则去谷歌
if(is_winnt4 || is_win95){document.location =" http://www.yahoo.com"}
else {document.location =" http://www.google.com"}
__________________________________________________ __
< Ri ** @ NeedsHelp.com>在消息新闻中写道:q _ *************** @ fe12.lga ...我正在尝试创建一个会重定向用户的网站基于他们的操作系统。
对于这个网站,我需要将NT4和95用户发送到站点A和2000 / XP
用户到站点B.
所有其他用户应该被定向到站点B.
提前致谢。
Rich
alu写道:这应该可以完成这项任务,它实际上会区分你需要的更多平台,只需删除不必要的行。
-alu
__________________________________________________ _
var n = navigator;
var ua =''''+ n.userAgent.toLowerCase();
//找到windows平台
var is_win = ua.indexOf( ''赢'')> 0;
< snip> var is_winnt4 =(ua.indexOf(''nt 4.0'')> 0& ua.indexOf(''win'')> 0);
< ; snip>
这似乎是基于以下假设:浏览器导航器对象的userAgent属性
表示
关于浏览器运行的操作系统的信息。
这个假设根本不是真的。
Richard。
I am trying to create a site that will re-direct a user based on their OS.
For this site I will need to send NT4 and 95 users to site A and 2000/XP
users to site B.
All others should be directed to site B.
Thanks in advance.
Rich
navigator.userAgent will deliver some information about the used os
micha
this should do the job, it actually discriminates between more platforms
than you require, just delete the unnecessary lines.
-alu
__________________________________________________ _
var n = navigator;
var ua = '' '' + n.userAgent.toLowerCase();
// find windows platform
var is_win = ua.indexOf(''win'') > 0;
var is_win16 = (ua.indexOf(''16'') > 0 && ua.indexOf(''win'') > 0);
var is_win31 = is_win16;
var is_win95 = (ua.indexOf(''95'') > 0 && ua.indexOf(''win'') > 0);
var is_win98 = (ua.indexOf(''98'') > 0 && ua.indexOf(''win'') > 0);
var is_winnt = (ua.indexOf(''nt'') > 0 && ua.indexOf(''win'') > 0);
var is_winnt4 = (ua.indexOf(''nt 4.0'') > 0 && ua.indexOf(''win'') > 0);
// go to yahoo if NT4 or win95, else go to Google
if(is_winnt4 || is_win95){document.location = "http://www.yahoo.com"}
else {document.location = "http://www.google.com"}
__________________________________________________ __
<Ri**@NeedsHelp.com> wrote in message news:q_***************@fe12.lga...I am trying to create a site that will re-direct a user based on their OS.
For this site I will need to send NT4 and 95 users to site A and 2000/XP
users to site B.
All others should be directed to site B.
Thanks in advance.
Rich
alu wrote:this should do the job, it actually discriminates between more
platforms than you require, just delete the unnecessary lines.
-alu
__________________________________________________ _
var n = navigator;
var ua = '' '' + n.userAgent.toLowerCase();
// find windows platform
var is_win = ua.indexOf(''win'') > 0; <snip> var is_winnt4 = (ua.indexOf(''nt 4.0'') > 0 && ua.indexOf(''win'') > 0);
<snip>
This appears to be based on the assumption that the userAgent property
of a browser''s navigator object represents an accurate source of
information about the operating system on which the browser is running.
That assumption simply is not true.
Richard.
这篇关于帮助 - 基于操作系统重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!