Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javascript Navigator OSCPU Undefined

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...

like image 882
WPF-it Avatar asked Apr 09 '26 04:04

WPF-it


1 Answers

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
like image 131
Raptor Avatar answered Apr 11 '26 00:04

Raptor



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!