从浏览器检测确切的操作系统版本

2021-12-25 00:00:00 browser php javascript

我想知道是否有一种方法可以使用 PHP/JS/ASP 从我的浏览器中检测到确切的操作系统版本?

I was wondering if there is a way I can detect the exact Operating System version from my browser using PHP/JS/ASP?

我知道我可以检测操作系统的类型(Windows XP、Windows Vista、OS X 等),但我需要检测确切的版本:Vista Business、Vista Ultimate、Windows XP Home、Windows XP Pro 等..

I know I can detect the type of OS (Windows XP,Windows Vista,OS X,etc) but I need to detect the exact version: Vista Business, Vista Ultimate, Windows XP Home, Windows XP Pro, etc...

推荐答案

简短回答:你不能.

长答案:

您所拥有的只是 HTTP User-Agent 标头中的信息,其中通常包含操作系统名称和版本.

All you have is the information in the HTTP User-Agent header, which usually contains the OS name and version.

通常,在 Mac OS 和 Linux 上运行的浏览器会发送足够的信息来识别确切的操作系统.例如,这是我的 User-Agent 标头:

Usually, browsers running on Mac OS and Linux send enough information to identify the exact OS. For example, here's my User-Agent header:

Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.0.7) Gecko/2009030423 Ubuntu/8.10 (intrepid) Firefox/3.0.7

Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.0.7) Gecko/2009030423 Ubuntu/8.10 (intrepid) Firefox/3.0.7

你可以看到我正在运行 Ubuntu 8.10 Intrepid Ibex.

You can see that I'm running Ubuntu 8.10 Intrepid Ibex.

以下是 Firefox 和 Safari 4 Beta 在我的 MacBook Pro 上的报告:

And here's what Firefox and Safari 4 Beta report on my MacBook Pro:

Mozilla/5.0(Macintosh;U;Intel Mac OS X 10.5;en-US;rv:1.9.0.7)Gecko/2009021906 Firefox/3.0.7

Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.0.7) Gecko/2009021906 Firefox/3.0.7

Mozilla/5.0(Macintosh;U;Intel Mac OS X 10_5_6;en-us)AppleWebKit/528.16(KHTML,如 Gecko)版本/4.0 Safari/528.16

Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_6; en-us) AppleWebKit/528.16 (KHTML, like Gecko) Version/4.0 Safari/528.16

另一方面,Windows 浏览器通常只报告操作系统版本而不是特定的软件包(Pro、Business 等):

Windows browsers, on the other hand, usually only report the OS version and not the specific package (Pro, Business, etc.):

Mozilla/5.0(Windows;U;Windows NT 5.1;en-US;rv:x.x.x)Gecko/20041107 Firefox/x.x

Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:x.x.x) Gecko/20041107 Firefox/x.x

相关文章