Determining OS Platform Version

In general, you should not care what Operating System visitors are using to visit your website. If you attempt to be clever, you will often get it wrong and cause problems that are an annoyance for users and a hassle for me to debug. So avoid trying to be nosy/clever if at all possible. ThatContinue reading “Determining OS Platform Version”


This content originally appeared on text/plain and was authored by ericlaw

In general, you should not care what Operating System visitors are using to visit your website. If you attempt to be clever, you will often get it wrong and cause problems that are an annoyance for users and a hassle for me to debug.

So avoid trying to be nosy/clever if at all possible.

That being said, some folks want to know for whatever reason; I’m an engineer, not a cop.

The typical path to get this information from Windows-based browsers is to look at the dreaded User-Agent string, a wretched hive of lies, scum, and villainy.

However, this approach falls down with Windows 11, which reports itself as Windows NT 10.0 (almost certainly for compatibility reasons); in general, browsers are moving toward freezing the User-Agent string to limit passive fingerprinting.

If you want to be able to distinguish between Windows 10 and Windows 11, starting around October 2021 in Microsoft Edge 95 (and v95 of most Chromium browsers), the Sec-Ch-UA-Platform-Version Client Hint is the way to go.

Available for request in v95, this value will indicate the UniversalApiContract “API Level” of the Windows platform. The mapping of values to version is

Windows VersionSec-CH-UA-Platform-Version
Windows 7 | 8 | 8.10.0.0
Windows 10 15071.0.0
Windows 10 15112.0.0
Windows 10 16073.0.0
Windows 10 17034.0.0
Windows 10 17095.0.0
Windows 10 18036.0.0
Windows 10 18097.0.0
Windows 10 1903 | 19098.0.0
Windows 10 2004 | 20H2 | 21H110.0.0
Windows 11 Previews13.0.0 | 14.0.0
Windows 11 Release15.0.0

You can request this Client Hint from JavaScript thusly:

navigator.userAgentData.getHighEntropyValues(['platformVersion'])
.then(uapv => { console.log(uapv.platformVersion); });

Or you can request it be sent to your server on subsequent requests using

Response.AddHeader("Accept-CH", "Sec-CH-UA-Platform-Version");
Response.AddHeader("Accept-CH-Lifetime", "86400");

As you may have noticed, the 0.0.0 value is shared across all pre-Windows 10 versions of Windows, so you’ll need to continue to use the User-Agent string to distinguish between Windows 7, 8.0, and 8.1 platforms.

As far as I know, Firefox does not plan to implement this Client Hint.

-Eric

PS: Native client apps should generally not check the registry key directly, instead it should query the appropriate “Is this API level supported” API. HKLM\SOFTWARE\Microsoft\WindowsRuntime\WellKnownContracts\Windows.Foundation.UniversalApiContract


This content originally appeared on text/plain and was authored by ericlaw


Print Share Comment Cite Upload Translate Updates
APA

ericlaw | Sciencx (2021-09-21T16:17:12+00:00) Determining OS Platform Version. Retrieved from https://www.scien.cx/2021/09/21/determining-os-platform-version/

MLA
" » Determining OS Platform Version." ericlaw | Sciencx - Tuesday September 21, 2021, https://www.scien.cx/2021/09/21/determining-os-platform-version/
HARVARD
ericlaw | Sciencx Tuesday September 21, 2021 » Determining OS Platform Version., viewed ,<https://www.scien.cx/2021/09/21/determining-os-platform-version/>
VANCOUVER
ericlaw | Sciencx - » Determining OS Platform Version. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/09/21/determining-os-platform-version/
CHICAGO
" » Determining OS Platform Version." ericlaw | Sciencx - Accessed . https://www.scien.cx/2021/09/21/determining-os-platform-version/
IEEE
" » Determining OS Platform Version." ericlaw | Sciencx [Online]. Available: https://www.scien.cx/2021/09/21/determining-os-platform-version/. [Accessed: ]
rf:citation
» Determining OS Platform Version | ericlaw | Sciencx | https://www.scien.cx/2021/09/21/determining-os-platform-version/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.