检测IE的Metro UI版本 [英] Detect Metro UI Version of IE
问题描述
什么是最快的方法,将 User-Agent 检测为 metro internet-explorer<的UI版本/a> >=10
?
What's the fastest method, to detect User-Agent as metro UI version of internet-explorer >=10
?
推荐答案
因此,似乎没有确定 Metro IE 与桌面 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版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!