开发者

Chek Windows Vista using Javascript

how can i found Windows Vista Service Pack开发者_如何转开发 version using javascript..


By using Javascript try alert(navigator.userAgent));

However I am not sure if, it is cross browser. Better way would be to use server side languages.

By using PHP, you can do this.

<? echo $_SERVER['HTTP_USER_AGENT']; ?>

Both, Javascript and PHP outputs something like this

Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.12) Gecko/20101026 Firefox/3.6.12

You can detect the OS using this output as Windows NT 6.1 is Windows 7


According to this MSDN article on user-agent strings you can assume that a user-agent platform token containing the string "Windows NT 6.0" indicates that the client machine is running Windows Vista. For example:

var isWindowsVista = function() {
  return (navigator.userAgent.indexOf("Windows NT 6.0") >= 0);
};
alert(isWindowsVista());

However, Windows 7 is called "Windows NT 6.1" so unless there are version numbers like 6.0.x.y then I doubt you can detect the Vista patch level in an "official" way. Perhaps there are browser/DOM quirks that could let you infer patch level differences though.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜