全球主机交流论坛

标题: Windows11无法通过UserAgent来获取系统版本号了 [打印本页]

作者: Ruclinux    时间: 2024-2-26 14:37
标题: Windows11无法通过UserAgent来获取系统版本号了
   给自己的博客增加了来客IP地址、IP所在位置、使用浏览器、使用系统等内容的功能,但是现在windows11无法通过UserAgent来获取了。

   请教各位大佬们,PHP还有什么办法获取到windows11的吗?谢谢了。
作者: zoujiayu    时间: 2024-2-26 14:43
if(navigator.userAgentData){//判断当前环境是否支持     navigator.userAgentData.getHighEntropyValues(["platformVersion"])  .then(ua => {    if (navigator.userAgentData.platform === "Windows") {//判断是否是Windows系统      const majorPlatformVersion = parseInt(ua.platformVersion.split('.')[0]);      if (majorPlatformVersion >= 13) {//判断是否是win11或以上        document.cookie = "win11=true;path=/";//写入cookie       }    } });}
作者: zxxx    时间: 2024-2-26 15:11
格式化一下
  1. if (navigator.userAgentData) { //判断当前环境是否支持
  2.   navigator.userAgentData.getHighEntropyValues(["platformVersion"]).then(ua => {
  3.     if (navigator.userAgentData.platform === "Windows") { //判断是否是Windows系统  
  4.       const majorPlatformVersion = parseInt(ua.platformVersion.split('.')[0]);
  5.       if (majorPlatformVersion >= 13) { //判断是否是win11或以上  
  6.         document.cookie = "win11=true;path=/"; //写入cookie   
  7.       }
  8.     }
  9.   });
  10. }
复制代码

作者: Ruclinux    时间: 2024-2-26 15:12
zoujiayu 发表于 2024-2-26 14:43
if(navigator.userAgentData){//判断当前环境是否支持     navigator.userAgentData.getHighEntropyValues( ...

谢谢您的回复,文章说这个http没有效果
作者: Ruclinux    时间: 2024-2-26 15:14
zxxx 发表于 2024-2-26 15:11
格式化一下

谢谢您的回复,这个是js的吗,好像说http没有效果
作者: hfhfg    时间: 2024-2-26 15:21
UserAgent里面如果没有提交Windows版本号,那就只能用JS代码通过浏览器API获取了。
作者: Ruclinux    时间: 2024-2-26 15:25
hfhfg 发表于 2024-2-26 15:21
UserAgent里面如果没有提交Windows版本号,那就只能用JS代码通过浏览器API获取了。 ...

谢谢您的回复
作者: zoujiayu    时间: 2024-2-27 01:00
Ruclinux 发表于 2024-2-26 15:12
谢谢您的回复,文章说这个http没有效果

我在vue下测试过http可用,可以获取到版本信息,把版本信息存在浏览器本地存储或提交给接口都行。
作者: Ruclinux    时间: 2024-3-13 14:38
zoujiayu 发表于 2024-2-27 01:00
我在vue下测试过http可用,可以获取到版本信息,把版本信息存在浏览器本地存储或提交给接口都行。 ...

谢谢您的回复




欢迎光临 全球主机交流论坛 (https://91ai.net/) Powered by Discuz! X3.4