从浏览器检测Windows 10 [英] Detect Windows 10 s from the browser

查看:95
本文介绍了从浏览器检测Windows 10的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在客户端运行Windows 10 S时将浏览器重定向到特定页面(特别是"S",仅Win 10是不够的).用户代理似乎没有指定它.

I have a requirement to redirect a browser to a particular page when the client is running Windows 10 S (specifically "S", just Win 10 isn't sufficient). The user agent doesn't seem to specify this.

我已经找到了在客户端上通过C ++和WMI获取此数据的解决方案,但是我需要在网页上运行类似Javascript的内容并推断客户端是否为10 S.

I have found solutions for getting this data via C++ and WMI on the client, but I need to run something like Javascript on a web page and infer if the client is 10 S.

在实现这一目标方面的任何帮助都将受到赞赏.

Any help in achieving this would be appreciated.

推荐答案

因此,我刚刚安装了Windows 10 S的新副本并运行了其默认浏览器Edge(其他任何浏览器都将具备可用)通过Windows应用商店访问,因为这是在此版本的Windows 10上运行应用程序的唯一方法.其中的 window.navigator.userAgent 与Windows 10 Pro极为相似,只不过有一个细微的细节:在操作系统信息后称为"ServiceUI 11".我的猜测是,这将是您找出网页是否在特定版本的Windows上运行的方式:

So I just installed a fresh copy of Windows 10 S and ran its default browser Edge (any other browser would have to be available through Windows Store as it is the only way to run apps on this edition of Windows 10). The window.navigator.userAgent in it was super similar to that of Windows 10 Pro except one tiny detail: something called "ServiceUI 11" after the OS info. My guess is that this would be the way for you to find out if the page is running on that particular edition of Windows:

function isWindows10S(){
  return window.navigator.userAgent.indexOf("ServiceUI") !== -1;
}

在Edge和Chrome的 S Pro 上进行了测试.

Tested it on S and Pro in Edge and Chrome.

在IE 11中尝试时,虽然得到了不同的结果.字符串为"Mozilla/5.0(Windows NT 10.0; WOW64; Trident/7.0; .NET4.0C ...)",并且在 S Pro 之间是相同的,因此看起来该方法仅适用于基于Gecko的现代浏览器:)

When tried in IE 11 though I've got a different result. The string was "Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; .NET4.0C..." and it was identical between the S and Pro so looks like that method only works for modern browsers that are based on Gecko :)

这篇关于从浏览器检测Windows 10的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆