Question

The navigator's oscpu attribute is throwing undefined on XP IE7 and WIN7 IE9 machines. Other attributes such as platform etc work fine.

 alert(navigator.oscpu);

I want to know how Javascript can identify the version of windows (Windows Xp, 7 or 8)

Can someone help?

EDIT:

Got the answer

navigator.appVersion return something like this...

4.0 (compatible; MSIE 7.0; MSBrowserIE7; Windows NT 5.1; .NET CLR 1.0.3705; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; MS-RTC LM 8; .NET4.0C; .NET4.0E; dmx:m; mty:p; slx:mi.by.as; ssx:NonCitrix)

So in this

Windows NT 5.1 means Windows XP. If it was Windows NT 6.1 it would mean Windows 7 & If it was Windows NT 6.2 it would mean Windows 8 etc.

Hope this helps...

Était-ce utile?

La solution

In Internet Explorer, use:

alert(navigator.cpuClass); // CPU info
alert(navigator.platform); // Operating System

It is not part of standards, we shouldn't rely on it.

Reference:

  1. http://help.dottoro.com/ljlhiaix.php
  2. window.navigator.oscpu on MDN
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top