1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

User-Agent クライアント ヒントを使用した Windows 11の判別

Posted at

2021年12月時点では、ユーザーエージェント(UA)から、Windows10とWindows11を判別することが出来ませんでしたが、javascriptによってUser-Agent クライアント ヒントを使用してWindows11を判別できる記事を見つけたので、メモ。

script.js

navigator.userAgentData.getHighEntropyValues(["platformVersion"])
 .then(ua => {
   if (navigator.userAgentData.platform === "Windows") {
     const majorPlatformVersion = parseInt(ua.platformVersion.split('.')[0]);
     if (majorPlatformVersion >= 13) {
       console.log("Windows 11 or later");
      }
      else if (majorPlatformVersion > 0) {
        console.log("Windows 10");
      }
      else {
        console.log("Before Windows 10");
      }
   }
   else {
     console.log("Not running on Windows");
   }
 });

【参考サイト】
https://docs.microsoft.com/ja-jp/microsoft-edge/web-platform/how-to-detect-win11

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?