Is there methods to detect Windows-11 vs Windows-10 in Firefox browser?

1.4k Views Asked by At

Currently,
    On Windows-11 devices I'm getting navigator.userAgent value as Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.5060.134 Safari/537.36 Edg/103.0.1264.77 which is same as Windows-10.

To distinguish between Windows-10 vs Windows-11, I have used User-Agent Client Hints

navigator.userAgentData.getHighEntropyValues(['platformVersion']).then(function(uapv){
    console.log(uapv.platformVersion); 
    var winVer = Number(uapv.platformVersion.split('.')[0]);
    if(winVer>10){
        console.log("It's Win11")
    }else{
        console.log("It's Not Win11");
    }
});

But,
    User-Agent Client Hints are only supported in Chrome/Edge/Opera but not in Firefox.

So, is there a technique/library available to detect Windows-11 in Firefox ?

1

There are 1 best solutions below

1
On

Try this library:

https://github.com/bestiejs/platform.js

Then, do platform.os and it should give you something like: Windows Server 2008 R2 / 7 x64 the 7 is the version here.