区分Mac OS X版本 [英] Distinguishing Mac OS X Versions

查看:82
本文介绍了区分Mac OS X版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法使用JavaScript来区分Mac OS X 10.4

和早期的OS X版本,如Windows? browserType.UserAgent

在10.4机器上输出以下内容,对于特定的操作系统,(对我来说)什么都不说




mozilla / 5.0(macintosh; u; ppc mac os x mach-o; en-us; rv:1.8.1.3)

gecko / 20070321 firefox / 2.0.0.3

>
谢谢,



解决方案

Thomas''PointedEars''Lahn说关注2007年8月7日下午1:31:

wi * *********@gmail.com 写道:


>有没有办法使用JavaScript来区分Mac OS X 10.4
以及早期的OS X版本与Windows一样吗?



没有这种方式,即使是Windows也没有。



IBTD

var OS =你在使用什么操作系统?;

< snip>


PointedEars



你的sigsep在错误的位置。

-

兰迪

机会有利于准备好的心灵

comp.lang.javascript常见问题 - http://jibbering.com/faq/index.html

Javascript最佳实践 - < a rel =nofollowhref =http://www.JavascriptToolbox.com/bestpractices/\"target =_ blank> http://www.JavascriptToolbox.com/bestpractices/


wi ********** @ gmail.com 写道:


有没有办法用JavaScript区分Mac OS X 10.4

和早期的OS X版本,比如Windows ? browserType.UserAgent

在10.4机器上输出以下内容,对于特定的操作系统,(对我来说)什么都不说




mozilla / 5.0(macintosh; u; ppc mac os x mach-o; en-us; rv:1.8.1.3)

gecko / 20070321 firefox / 2.0.0.3


您可以将一些逻辑应用于Safari版本号,以确定操作系统版本。使用Firefox,你不会那么幸运。对于

Firefox,你可以确定的最好的是它是英特尔处理器

(因此> = Tiger)。这是一个wiki页面(有一个很长的URL)

那个与你创建的需求相同的人:
http://tinyurl.com/2b68bw


你需要过滤掉这个微观方面的其他人谁会告诉你你不能依赖用户代理的
。他们不是生活在现实世界中,而是奢侈地告诉他们的雇主不。任何要求

的请求都会产生需要查看用户代理字符串的代码。我们必须与现实生活在一起的那些美元知道用户代理是我们已经获得的最佳信息,并且我们需要它来完成工作。我已经试图避开他们所拥有的线程,因为他们之间只是来回徘徊。当我看到他们强迫那个像你自己那样毫无戒心的noob时,我不想让他们说服你(说到目前为止两个回复)你不能做什么

什么的。你可以做点什么而且总比没有好。我是

假设您真正需要它并且不能进行特征检测。


< / js>


Johannes Schmidt写道:


你需要过滤掉这个微观方面的其他人谁会告诉你

,你不能依赖用户代理。他们不是生活在现实世界中,而是奢侈地告诉他们的雇主不。任何要求

的请求都会产生需要查看用户代理字符串的代码。



你是故意迟钝还是只是在心里无能为力?


正确的答案是:*不*,你*可以* *不*依赖于User-Agent标题

或navigator.userAgent。你也不需要,那里

*更好*促进优雅降级的手段。


我们已经在这里详细讨论了浏览器检测的缺陷,

在FAQ备注中甚至有关于它的部分。


我们这些必须与现实生活在一起的人知道用户代理是

最好的信息我们有[...]



告诉我,你的平行宇宙中的天气怎么样? ?

PointedEars,附随机随机信号

-

var bugRiddenCrashPronePieceOfJunk =(

navigator.userAgent。 indexOf(''MSIE 5'')!= -1

&& navigator.userAgent.indexOf(''Mac'')!= -1

) // Plone,register_function.js:16


Is there a way to use JavaScript to distinguish between Mac OS X 10.4
and earlier OS X versions like with Windows? browserType.UserAgent
outputs the following on a 10.4 machine, which (to me) says nothing
about the specific OS:

mozilla/5.0 (macintosh; u; ppc mac os x mach-o; en-us; rv:1.8.1.3)
gecko/20070321 firefox/2.0.0.3

Thanks,
Will

解决方案

Thomas ''PointedEars'' Lahn said the following on 8/7/2007 1:31 PM:

wi**********@gmail.com wrote:

>Is there a way to use JavaScript to distinguish between Mac OS X 10.4
and earlier OS X versions like with Windows?


There is no such way, not even with Windows.


IBTD
var OS = "What Operating System are you using?";
<snip>

PointedEars

Your sigsep is in the wrong place.
--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/


wi**********@gmail.com wrote:

Is there a way to use JavaScript to distinguish between Mac OS X 10.4
and earlier OS X versions like with Windows? browserType.UserAgent
outputs the following on a 10.4 machine, which (to me) says nothing
about the specific OS:

mozilla/5.0 (macintosh; u; ppc mac os x mach-o; en-us; rv:1.8.1.3)
gecko/20070321 firefox/2.0.0.3

There is some logic you can apply to the Safari version number to
determine the OS version. With Firefox you won''t be so lucky. For
Firefox the best you can determine is whether it''s an Intel processor
(and therefore >= Tiger) or not. Here''s a wiki page (with a long URL)
that someone with the same need as you created:
http://tinyurl.com/2b68bw

You need to filter out the others in this microverse who''ll tell you
that you can''t rely on the user agent. They don''t live in the real world
and have the luxury of telling their employers "NO" to any request to
produce code that would require looking at the user agent string. Those
of us that have to live with reality know that the user agent is the
best info we''ve got and does the job as well as we need it to. I''ve
tried staying out of the threads they had about it because they were
just back and forth amongst themselves. When I see them force that
diatribe on an unsuspecting noob like yourself then I don''t want to let
them convince you (with the two replies so far) that you can''t do
anything. You can do something and it''s better than nothing. I''m
assuming you have a genuine need for it and can''t do feature detection.

</js>


Johannes Schmidt wrote:

You need to filter out the others in this microverse who''ll tell you
that you can''t rely on the user agent. They don''t live in the real world
and have the luxury of telling their employers "NO" to any request to
produce code that would require looking at the user agent string.

Are you being deliberately obtuse or are you just mindboggingly incompetent?

The correct answer is: *No*, you *can* *not* rely on the User-Agent header
or on navigator.userAgent for that matter. Nor are you required to, there
are *far better* means to facilitate graceful degradation.

We have discussed the pitfalls of browser detection at great length here,
there is even a section about it in the FAQ Notes.

Those of us that have to live with reality know that the user agent is the
best info we''ve got [...]

Tell me, how is the weather in your parallel universe?
PointedEars, with a fitting random sig
--
var bugRiddenCrashPronePieceOfJunk = (
navigator.userAgent.indexOf(''MSIE 5'') != -1
&& navigator.userAgent.indexOf(''Mac'') != -1
) // Plone, register_function.js:16


这篇关于区分Mac OS X版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆