Detect Metro UI Version of IE(检测 IE 的 Metro UI 版本)
问题描述
什么是最快的方法,将 User-Agent 检测为 metro internet-explorer >=10
?
What's the fastest method, to detect User-Agent as metro UI version of internet-explorer >=10
?
推荐答案
所以,似乎没有明确的测试来识别 Metro IE 与 Desktop IE,但您似乎确实有一些不同的数据可以尝试使用来假设它是 Metro.不幸的是,我发现的所有项目都无法通过其他设置来解释.换句话说,对于我发现的所有功能"测试,Desktop IE 可以配置为诱使测试认为它是在 Metro 上运行的.
So, there doesn't appear to be a definitive test to identify Metro IE vs Desktop IE, but there does seem to be a few different pieces of data you can attempt to use to assume that it is Metro. Unfortunately, none of the items I have found can't be explained away by other settings. In other words, for all the "feature" tests I have found, Desktop IE could be configured in a way to trick the tests into thinking it was running on Metro.
是否禁用 ActiveX(Metro 不允许任何 activex 内容,但桌面 IE 也可以将其设置为禁用):
Is ActiveX disabled (Metro doesn't allow any activex content, but desktop IE can have it set to disabled as well):
function isActivexEnabled() {
var supported = null;
try {
supported = !!new ActiveXObject("htmlfile");
} catch (e) {
supported = false;
}
return supported;
}
用户代理字符串检查(Metro 将始终在 64 位模式下运行,但不会在 32 位机器上运行,并且桌面 IE 可以配置为在 64 位模式下运行,不确定这些选项中的任何一个有多受欢迎)
User Agent string check (Metro will always run in 64bit mode, but won't on a 32bit machine, and Desktop IE can be configured to run in 64bit mode as well not sure how popular either of those options will be)
function isWin64() {
return navigator.platform == "Win64";
}
全屏检查(Metro 将始终处于全屏模式,但桌面 IE 也可以以全屏模式运行,但这可以作为 Metro 模式的支持证据)
Full screen check (Metro will always be in full screen mode, however Desktop IE can also run in full screen mode, but this could be used as supporting evidence of Metro mode)
function isFullScreen() {
return (window.innerWidth == screen.width &&
window.innerHeight == screen.height);
}
简而言之,我认为您必须尝试检查一堆功能,然后猜测,没有确定的方法.或者您可以接受 MS 不希望您这样做,并对您想要使用的功能使用功能检测.
In short, I think you have to try to check a bunch of features, and then guess, there is no definitive way. Or you could just accept that MS doesn't want you to do this, and use feature detection for the features you want to use.
对于那些想要尝试提供 UI 以引用包含浏览器 UI(例如指示如何固定网页)的用户,请记住其他 Metro 应用程序可以将 IE10 Metro 浏览器嵌入为控件,因此即使您可以将浏览器识别为 Metro 与桌面,UI 也可能不是您试图引用它的地方,因此这最终可能是一个非常棘手的情况,要在 100% 的时间里正确.因此,要么不要尝试,要么您可以尝试其他检测技术并接受您可能会显示错误 UI 的用例.
For those that want to try to provide UI to refer to the containing browser UI (to indicate how to Pin the web page for example), keep in mind that other Metro apps can embed the IE10 Metro browser as a control, so even if you could identify the browser as Metro vs desktop, the UI might not be where you'd attempt to refer to it, so this can end up being a pretty tricky situation to get right 100% of the time. So either, don't try, or you could attempt the other detection techniques and accept that there are use cases that you could be displaying the wrong UI.
这篇关于检测 IE 的 Metro UI 版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:检测 IE 的 Metro UI 版本
- addEventListener 在 IE 11 中不起作用 2022-01-01
- Fetch API 如何获取响应体? 2022-01-01
- 使用RSelum从网站(报纸档案)中抓取多个网页 2022-09-06
- Css:将嵌套元素定位在父元素边界之外一点 2022-09-07
- 失败的 Canvas 360 jquery 插件 2022-01-01
- CSS媒体查询(最大高度)不起作用,但为什么? 2022-01-01
- Flexslider 箭头未正确显示 2022-01-01
- Quasar 2+Apollo:错误:找不到ID为默认的Apollo客户端。如果您在组件设置之外,请使用ProvideApolloClient() 2022-01-01
- 400或500级别的HTTP响应 2022-01-01
- 如何使用 JSON 格式的 jQuery AJAX 从 .cfm 页面输出查 2022-01-01